Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/tweets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,13 @@ export async function getLatestTweet(
): Promise<Tweet | null | void> {
const timeline = getTweets(user, max, auth);

// No point looping if max is 1, just use first entry.
return max === 1
? (await timeline.next()).value
: await getTweetWhere(timeline, { isRetweet: includeRetweets });
return getTweetWhere(timeline, (tweet) => {
// Skip pinned tweets; they always appear first in the timeline.
if (tweet.isPin) return false;
// If includeRetweets is false, skip retweets too.
if (!includeRetweets && tweet.isRetweet) return false;
return true;
});
}

export interface TweetResultByRestId {
Expand Down