From bff6aedecf007a4225bf30e1800933a9005cb0b2 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 31 Aug 2024 03:54:14 +0100 Subject: [PATCH] Show some known OP replies in Following (#5049) * Show known OP replies in Following * Fiter by >0 parent likes --- src/lib/api/feed-manip.ts | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts index a0ee647b..094f892a 100644 --- a/src/lib/api/feed-manip.ts +++ b/src/lib/api/feed-manip.ts @@ -366,11 +366,7 @@ export class FeedTuner { ): FeedViewPostsSlice[] => { for (let i = 0; i < slices.length; i++) { const slice = slices[i] - if ( - slice.isReply && - !slice.isRepost && - !shouldDisplayReplyInFollowing(slice.getAuthors(), userDid) - ) { + if (slice.isReply && !shouldDisplayReplyInFollowing(slice, userDid)) { slices.splice(i, 1) i-- } @@ -434,9 +430,13 @@ function areSameAuthor(authors: AuthorContext): boolean { } function shouldDisplayReplyInFollowing( - authors: AuthorContext, + slice: FeedViewPostsSlice, userDid: string, ): boolean { + if (slice.isRepost) { + return true + } + const authors = slice.getAuthors() const {author, parentAuthor, grandparentAuthor, rootAuthor} = authors if (!isSelfOrFollowing(author, userDid)) { // Only show replies from self or people you follow. @@ -450,6 +450,21 @@ function shouldDisplayReplyInFollowing( // Always show self-threads. return true } + if ( + parentAuthor && + parentAuthor.did !== author.did && + rootAuthor && + rootAuthor.did === author.did && + slice.items.length > 2 + ) { + // If you follow A, show A -> someone[>0 likes] -> A chains too. + // This is different from cases below because you only know one person. + const parentPost = slice.items[1].post + const parentLikeCount = parentPost.likeCount ?? 0 + if (parentLikeCount > 0) { + return true + } + } // From this point on we need at least one more reason to show it. if ( parentAuthor &&