diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-16 14:49:58 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-01-16 14:49:58 -0600 |
commit | 1b5c34766702eab7ef26c9d898a3282aa6020a43 (patch) | |
tree | b43bb14b4128b772ea703ec3a51273ce1cf8d475 /src/state/models/feed-view.ts | |
parent | 29020fbcee0d2e07575ea6eab62ad56451cf377e (diff) | |
download | voidsky-1b5c34766702eab7ef26c9d898a3282aa6020a43.tar.zst |
Fix: remove duplicates in the TL caused by rendering reply parents
Diffstat (limited to 'src/state/models/feed-view.ts')
-rw-r--r-- | src/state/models/feed-view.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts index e5a6d73db..5f2b9721e 100644 --- a/src/state/models/feed-view.ts +++ b/src/state/models/feed-view.ts @@ -30,6 +30,7 @@ export class FeedItemModel { _isThreadParent: boolean = false _isThreadChildElided: boolean = false _isThreadChild: boolean = false + _hideParent: boolean = true // used to avoid dup post rendering while showing some parents // data post: PostView @@ -463,6 +464,7 @@ export class FeedModel { } else { this.feed = this.feed.concat(toAppend) } + dedupParents(this.feed) }) } @@ -601,6 +603,29 @@ function preprocessFeed(feed: FeedViewPost[]): FeedViewPostWithThreadMeta[] { return reorg } +function dedupParents(feed: FeedItemModel[]) { + // only show parents that aren't already in the feed + // NOTE if a parent post arrives in a followup loadmore, it'll show when we otherwise wish it wouldnt -prf + for (let i = 0; i < feed.length; i++) { + const item1 = feed[i] + if (!item1.replyParent || item1._isThreadChild) { + continue + } + let hideParent = false + for (let j = 0; j < feed.length; j++) { + const item2 = feed[j] + if ( + item1.replyParent.post.uri === item2.post.uri || // the post itself is there + (j < i && item1.replyParent.post.uri === item2.replyParent?.post.uri) // another reply already showed it + ) { + hideParent = true + break + } + } + item1._hideParent = hideParent + } +} + function getSelfReplyUri(item: FeedViewPost): string | undefined { return item.reply?.parent.author.did === item.post.author.did ? item.reply?.parent.uri |