about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/state/models/feed-view.ts18
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) {