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.
This commit is contained in:
Marcel Hellkamp 2024-12-19 15:51:24 +01:00
parent 263aef3671
commit ceea0b4aff

View File

@ -85,10 +85,14 @@ export async function fetchPosts(cfg: Config, onProgress: (progress: Progress) =
const addOrReplacePost = (post: Post) => { const addOrReplacePost = (post: Post) => {
const posts = progress.posts; const posts = progress.posts;
const i = posts.findIndex(p => p.id === post.id) const i = posts.findIndex(p => p.id === post.id)
if (i >= 0) if(i < 0) {
posts[i] = post // Add new posts to the end of the list
else
posts.unshift(post) 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 => { const fixLocalAcct = (domain: string, status: MastodonStatus): MastodonStatus => {