Skip to content

Commit

Permalink
Appview: apply needs-review to individual records (#3532)
Browse files Browse the repository at this point in the history
appview: apply needs-review to individual records
  • Loading branch information
devinivy authored Feb 14, 2025
1 parent 809c7ac commit 3c7976a
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 116 deletions.
2 changes: 1 addition & 1 deletion packages/bsky/src/api/app/bsky/feed/getQuotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const noBlocksOrNeedsReview = (inputs: {
return (
!ctx.views.viewerBlockExists(authorDid, hydration) &&
!hydration.postBlocks?.get(uri)?.embed &&
ctx.views.viewerSeesNeedsReview(authorDid, hydration)
ctx.views.viewerSeesNeedsReview({ did: authorDid, uri }, hydration)
)
})
return skeleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const noBlockOrMutesOrNeedsReview = (
item.reason === 'like' ||
item.reason === 'follow'
) {
if (!ctx.views.viewerSeesNeedsReview(did, hydration)) {
if (!ctx.views.viewerSeesNeedsReview({ did, uri: item.uri }, hydration)) {
return false
}
}
Expand Down
24 changes: 17 additions & 7 deletions packages/bsky/src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,23 @@ export class Views {
return uri
}

viewerSeesNeedsReview(did: string, state: HydrationState): boolean {
viewerSeesNeedsReview(
{ did, uri }: { did?: string; uri?: string },
state: HydrationState,
): boolean {
const { labels, profileViewers, ctx } = state
return (
!labels?.get(did)?.needsReview ||
ctx?.viewer === did ||
!!profileViewers?.get(did)?.following
)
did = did || (uri && uriToDid(uri))
if (!did) {
return true
}
if (
labels?.get(did)?.needsReview ||
(uri && labels?.get(uri)?.needsReview)
) {
// content marked as needs review
return ctx?.viewer === did || !!profileViewers?.get(did)?.following
}
return true
}

replyIsHiddenByThreadgate(
Expand Down Expand Up @@ -972,7 +982,7 @@ export class Views {
if (this.viewerBlockExists(post.author.did, state)) {
return this.blockedPost(uri, post.author.did, state)
}
if (!this.viewerSeesNeedsReview(post.author.did, state)) {
if (!this.viewerSeesNeedsReview({ uri, did: post.author.did }, state)) {
return undefined
}
return {
Expand Down
Loading

0 comments on commit 3c7976a

Please sign in to comment.