about summary refs log tree commit diff
path: root/src/lib/api
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-08-02 17:13:31 +0100
committerGitHub <noreply@github.com>2024-08-02 17:13:31 +0100
commit293ac6fab21f26baa8347c998f3a50224112c7c5 (patch)
tree623c92626097814678fbf9dde6c170250d80523b /src/lib/api
parent7f292abf51a4cd4e25702c33a3ed75f25be5b3a3 (diff)
downloadvoidsky-293ac6fab21f26baa8347c998f3a50224112c7c5.tar.zst
Only show replies in Following if following all involved actors (#4869)
* Only show replies in Following for followed root and grandparent

* Remove now-unnecessary check

* Simplify condition
Diffstat (limited to 'src/lib/api')
-rw-r--r--src/lib/api/feed-manip.ts44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts
index 01f05685d..7ddb79434 100644
--- a/src/lib/api/feed-manip.ts
+++ b/src/lib/api/feed-manip.ts
@@ -82,10 +82,6 @@ export class FeedViewPostsSlice {
     return AppBskyFeedDefs.isReasonRepost(reason)
   }
 
-  get includesThreadRoot() {
-    return !this.items[0].reply
-  }
-
   get likeCount() {
     return this._feedPost.post.likeCount ?? 0
   }
@@ -119,20 +115,19 @@ export class FeedViewPostsSlice {
 
   isFollowingAllAuthors(userDid: string) {
     const feedPost = this._feedPost
-    if (feedPost.post.author.did === userDid) {
-      return true
-    }
-    if (AppBskyFeedDefs.isPostView(feedPost.reply?.parent)) {
-      const parent = feedPost.reply?.parent
-      if (parent?.author.did === userDid) {
-        return true
+    const authors = [feedPost.post.author]
+    if (feedPost.reply) {
+      if (AppBskyFeedDefs.isPostView(feedPost.reply.parent)) {
+        authors.push(feedPost.reply.parent.author)
+      }
+      if (feedPost.reply.grandparentAuthor) {
+        authors.push(feedPost.reply.grandparentAuthor)
+      }
+      if (AppBskyFeedDefs.isPostView(feedPost.reply.root)) {
+        authors.push(feedPost.reply.root.author)
       }
-      return (
-        parent?.author.viewer?.following &&
-        feedPost.post.author.viewer?.following
-      )
     }
-    return false
+    return authors.every(a => a.did === userDid || a.viewer?.following)
   }
 }
 
@@ -304,19 +299,14 @@ export class FeedTuner {
       tuner: FeedTuner,
       slices: FeedViewPostsSlice[],
     ): FeedViewPostsSlice[] => {
-      // remove any replies without at least minLikes likes
       for (let i = slices.length - 1; i >= 0; i--) {
         const slice = slices[i]
-        if (slice.isReply) {
-          if (slice.isThread && slice.includesThreadRoot) {
-            continue
-          }
-          if (slice.isRepost) {
-            continue
-          }
-          if (!slice.isFollowingAllAuthors(userDid)) {
-            slices.splice(i, 1)
-          }
+        if (
+          slice.isReply &&
+          !slice.isRepost &&
+          !slice.isFollowingAllAuthors(userDid)
+        ) {
+          slices.splice(i, 1)
         }
       }
       return slices