about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/state/models/feed-view.ts25
-rw-r--r--src/view/com/posts/FeedItem.tsx3
2 files changed, 27 insertions, 1 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
diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx
index 7a1aa5d23..f7db827bd 100644
--- a/src/view/com/posts/FeedItem.tsx
+++ b/src/view/com/posts/FeedItem.tsx
@@ -96,7 +96,8 @@ export const FeedItem = observer(function ({
     return <View />
   }
 
-  const isChild = item._isThreadChild || (!item.reason && item.reply)
+  const isChild =
+    item._isThreadChild || (!item.reason && !item._hideParent && item.reply)
   const isSmallTop = isChild && item._isThreadChild
   const isNoTop = isChild && !item._isThreadChild
   const outerStyles = [