Skip to content

Commit

Permalink
Show some known OP replies in Following (bluesky-social#5049)
Browse files Browse the repository at this point in the history
* Show known OP replies in Following

* Fiter by >0 parent likes
  • Loading branch information
gaearon authored Aug 31, 2024
1 parent 3d992f6 commit bff6aed
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/lib/api/feed-manip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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--
}
Expand Down Expand Up @@ -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.
Expand All @@ -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 &&
Expand Down

0 comments on commit bff6aed

Please sign in to comment.