Show some known OP replies in Following (#5049)

* Show known OP replies in Following

* Fiter by >0 parent likes
zio/stable
dan 2024-08-31 03:54:14 +01:00 committed by GitHub
parent 3d992f6bb5
commit bff6aedecf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 6 deletions

View File

@ -366,11 +366,7 @@ export class FeedTuner {
): FeedViewPostsSlice[] => { ): FeedViewPostsSlice[] => {
for (let i = 0; i < slices.length; i++) { for (let i = 0; i < slices.length; i++) {
const slice = slices[i] const slice = slices[i]
if ( if (slice.isReply && !shouldDisplayReplyInFollowing(slice, userDid)) {
slice.isReply &&
!slice.isRepost &&
!shouldDisplayReplyInFollowing(slice.getAuthors(), userDid)
) {
slices.splice(i, 1) slices.splice(i, 1)
i-- i--
} }
@ -434,9 +430,13 @@ function areSameAuthor(authors: AuthorContext): boolean {
} }
function shouldDisplayReplyInFollowing( function shouldDisplayReplyInFollowing(
authors: AuthorContext, slice: FeedViewPostsSlice,
userDid: string, userDid: string,
): boolean { ): boolean {
if (slice.isRepost) {
return true
}
const authors = slice.getAuthors()
const {author, parentAuthor, grandparentAuthor, rootAuthor} = authors const {author, parentAuthor, grandparentAuthor, rootAuthor} = authors
if (!isSelfOrFollowing(author, userDid)) { if (!isSelfOrFollowing(author, userDid)) {
// Only show replies from self or people you follow. // Only show replies from self or people you follow.
@ -450,6 +450,21 @@ function shouldDisplayReplyInFollowing(
// Always show self-threads. // Always show self-threads.
return true 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. // From this point on we need at least one more reason to show it.
if ( if (
parentAuthor && parentAuthor &&