diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-17 10:45:37 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-01-17 10:45:37 -0600 |
commit | e5ec07b919df97b44294e9bd7954ad244ee149d4 (patch) | |
tree | ccec945280d6ebf940bd7e7016f56cefba27a36e /src | |
parent | e11d53b67d7b50990320c4b5206ef052b0ff834c (diff) | |
download | voidsky-e5ec07b919df97b44294e9bd7954ad244ee149d4.tar.zst |
Remove duplicate posts caused by reposts
Diffstat (limited to 'src')
-rw-r--r-- | src/state/models/feed-view.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts index c39daf874..5f8fc98fe 100644 --- a/src/state/models/feed-view.ts +++ b/src/state/models/feed-view.ts @@ -457,6 +457,7 @@ export class FeedModel { } else { this.feed = this.feed.concat(toAppend) } + dedupReposts(this.feed) dedupParents(this.feed) }) } @@ -595,9 +596,24 @@ function preprocessFeed(feed: FeedViewPost[]): FeedViewPostWithThreadMeta[] { return reorg } +// WARNING: mutates `feed` +function dedupReposts(feed: FeedItemModel[]) { + // remove duplicates caused by reposts + for (let i = 0; i < feed.length; i++) { + const item1 = feed[i] + for (let j = i + 1; j < feed.length; j++) { + const item2 = feed[j] + if (item1.post.uri === item2.post.uri) { + feed.splice(j, 1) + j-- + } + } + } +} + +// WARNING: mutates `feed` 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) { |