Skip to content

Commit 6916004

Browse files
committed
fix(router/twitter): fix converstaion root post missing
1 parent dfb39a2 commit 6916004

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

lib/routes/twitter/api/mobile-api/api.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ function gatherLegacyFromData(entries, filterNested?, userId?) {
188188
return tweets;
189189
}
190190

191-
const getUserTweetsByID = async (id, params = {}) => gatherLegacyFromData(await timelineTweets(id, params));
191+
const getUserTweetsByID = async (id, params = {}) => {
192+
// Keep only root posts; drop replies and self-thread continuations from profile-conversation modules
193+
const tweets = gatherLegacyFromData(await timelineTweets(id, params), ['profile-conversation-'], id);
194+
return tweets.filter((t) => !t.in_reply_to_status_id_str);
195+
};
192196
// TODO: show the whole conversation instead of just the reply tweet
193197
const getUserTweetsAndRepliesByID = async (id, params = {}) => gatherLegacyFromData(await timelineTweetsAndReplies(id, params), ['profile-conversation-'], id);
194198
const getUserMediaByID = async (id, params = {}) => gatherLegacyFromData(await timelineMedia(id, params));

lib/routes/twitter/api/web-api/api.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,22 @@ const cacheTryGet = async (_id, params, operationName, func) => {
5353
};
5454

5555
const getUserTweets = (id: string, params?: Record<string, any>) =>
56-
cacheTryGet(id, params, 'getUserTweets', async (id, params = {}) =>
57-
gatherLegacyFromData(
56+
cacheTryGet(id, params, 'getUserTweets', async (id, params = {}) => {
57+
const tweets = gatherLegacyFromData(
5858
await paginationTweets('UserTweets', id, {
5959
...params,
6060
count: 20,
6161
includePromotedContent: true,
6262
withQuickPromoteEligibilityTweetFields: true,
6363
withVoice: true,
6464
withV2Timeline: true,
65-
})
66-
)
67-
);
65+
}),
66+
['profile-conversation-'],
67+
id
68+
);
69+
// Keep only root posts; drop replies and self-thread continuations from profile-conversation modules
70+
return tweets.filter((t) => !t.in_reply_to_status_id_str);
71+
});
6872

6973
const getUserTweetsAndReplies = (id: string, params?: Record<string, any>) =>
7074
cacheTryGet(id, params, 'getUserTweetsAndReplies', async (id, params = {}) =>

0 commit comments

Comments
 (0)