From 28267e025d0b64a157069f06dba59263f1a67d4d Mon Sep 17 00:00:00 2001 From: Mohamed Radwan <267492103+mohamedorigami-jpg@users.noreply.github.com> Date: Sat, 6 Jun 2026 18:45:23 +0300 Subject: [PATCH] fix: getLatestTweet should skip pinned tweet Updates getLatestTweet() to filter out pinned tweets when iterating through the user timeline. Pinned tweets always appear first in the timeline response, so they were being returned as the 'latest' tweet. The Tweet type already had an isPin field populated by both the V1 and V2 timeline parsers, so this just adds a check in getLatestTweet to skip any tweet where isPin is true. Closes #164 --- src/tweets.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tweets.ts b/src/tweets.ts index c427d146..0d00fb94 100644 --- a/src/tweets.ts +++ b/src/tweets.ts @@ -377,10 +377,13 @@ export async function getLatestTweet( ): Promise { 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 {