Skip to content

Commit ceea0b4

Browse files
committed
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.
1 parent 263aef3 commit ceea0b4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/sources.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ export async function fetchPosts(cfg: Config, onProgress: (progress: Progress) =
8585
const addOrReplacePost = (post: Post) => {
8686
const posts = progress.posts;
8787
const i = posts.findIndex(p => p.id === post.id)
88-
if (i >= 0)
89-
posts[i] = post
90-
else
88+
if(i < 0) {
89+
// Add new posts to the end of the list
9190
posts.unshift(post)
91+
} else if (posts[i].date < post.date) {
92+
// If there are two posts with the same ID, keep the more recent one.
93+
// This is so that posts appear more recent if they are boosted.
94+
posts[i] = post
95+
}
9296
}
9397

9498
const fixLocalAcct = (domain: string, status: MastodonStatus): MastodonStatus => {

0 commit comments

Comments
 (0)