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
zio/stable
dan 2024-08-02 17:13:31 +01:00 committed by GitHub
parent 7f292abf51
commit 293ac6fab2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 27 deletions

View File

@ -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
const authors = [feedPost.post.author]
if (feedPost.reply) {
if (AppBskyFeedDefs.isPostView(feedPost.reply.parent)) {
authors.push(feedPost.reply.parent.author)
}
if (AppBskyFeedDefs.isPostView(feedPost.reply?.parent)) {
const parent = feedPost.reply?.parent
if (parent?.author.did === userDid) {
return true
if (feedPost.reply.grandparentAuthor) {
authors.push(feedPost.reply.grandparentAuthor)
}
return (
parent?.author.viewer?.following &&
feedPost.post.author.viewer?.following
)
if (AppBskyFeedDefs.isPostView(feedPost.reply.root)) {
authors.push(feedPost.reply.root.author)
}
return false
}
return authors.every(a => a.did === userDid || a.viewer?.following)
}
}
@ -304,21 +299,16 @@ 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)) {
if (
slice.isReply &&
!slice.isRepost &&
!slice.isFollowingAllAuthors(userDid)
) {
slices.splice(i, 1)
}
}
}
return slices
}
}