From ceea0b4affa9e496813fb3bffc49b5ef3eea01b0 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Thu, 19 Dec 2024 15:51:24 +0100 Subject: [PATCH] fix: Keep most recent version of each post. The date of a post is the boost date in case of a reblog. This is intentional, because popular (boosted) posts should move up again. This change ensures that we always display the most recent post/boost. --- src/sources.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sources.ts b/src/sources.ts index 54df695..4a0c958 100644 --- a/src/sources.ts +++ b/src/sources.ts @@ -85,10 +85,14 @@ export async function fetchPosts(cfg: Config, onProgress: (progress: Progress) = const addOrReplacePost = (post: Post) => { const posts = progress.posts; const i = posts.findIndex(p => p.id === post.id) - if (i >= 0) - posts[i] = post - else + if(i < 0) { + // Add new posts to the end of the list posts.unshift(post) + } else if (posts[i].date < post.date) { + // If there are two posts with the same ID, keep the more recent one. + // This is so that posts appear more recent if they are boosted. + posts[i] = post + } } const fixLocalAcct = (domain: string, status: MastodonStatus): MastodonStatus => {