fix: harden home timeline pagination (#31) (thanks @odysseus0)

This commit is contained in:
Peter Steinberger
2026-01-11 11:36:59 +00:00
parent 92742cac38
commit 94773c66dc
3 changed files with 96 additions and 2 deletions
+3 -1
View File
@@ -163,18 +163,20 @@ export function withHome<TBase extends AbstractConstructor<TwitterClientBase>>(
return { success: false, error: page.error };
}
let added = 0;
for (const tweet of page.tweets) {
if (seen.has(tweet.id)) {
continue;
}
seen.add(tweet.id);
tweets.push(tweet);
added += 1;
if (tweets.length >= count) {
break;
}
}
if (!page.cursor || page.cursor === cursor || page.tweets.length === 0) {
if (!page.cursor || page.cursor === cursor || page.tweets.length === 0 || added === 0) {
break;
}
cursor = page.cursor;