Skip to content

Commit

Permalink
better handle 3rd party blocks inf eeds
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Sep 26, 2023
1 parent 7dacb9d commit 142f068
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/bsky/src/services/feed/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export class FeedViews {
labels,
lists,
)
// skip over not found & blocked posts
if (!post || blocks[post.uri]?.reply) {
// skip over not found post
if (!post) {
continue
}
const feedPost = { post }
Expand All @@ -142,6 +142,7 @@ export class FeedViews {
) {
const replyParent = this.formatMaybePostView(
item.replyParent,
item.uri,
actors,
posts,
threadgates,
Expand All @@ -153,6 +154,7 @@ export class FeedViews {
)
const replyRoot = this.formatMaybePostView(
item.replyRoot,
item.uri,
actors,
posts,
threadgates,
Expand Down Expand Up @@ -219,6 +221,7 @@ export class FeedViews {

formatMaybePostView(
uri: string,
replyUri: string | null,
actors: ActorInfoMap,
posts: PostInfoMap,
threadgates: ThreadgateInfoMap,
Expand Down Expand Up @@ -246,7 +249,7 @@ export class FeedViews {
if (
post.author.viewer?.blockedBy ||
post.author.viewer?.blocking ||
blocks[uri]?.reply
(replyUri !== null && blocks[replyUri]?.reply)
) {
if (!opts?.usePostViewUnion) return
return this.blockedPost(post)
Expand Down
3 changes: 2 additions & 1 deletion packages/bsky/tests/views/blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ describe('pds views with blocking', () => {
const replyBlockedPost = timeline.feed.find(
(item) => item.post.uri === replyBlockedUri,
)
expect(replyBlockedPost).toBeUndefined()
assert(replyBlockedPost)
expect(replyBlockedPost.reply?.parent).toBeUndefined()
const embedBlockedPost = timeline.feed.find(
(item) => item.post.uri === embedBlockedUri,
)
Expand Down

0 comments on commit 142f068

Please sign in to comment.