Fix undefined block (#4479)

* Fix undefined block (#4378)

* Fix undefined block

* Changing text and handling all blocks.

* Tweaks

* Update copy, make non-interactive

* Remove console

* Clarify logic

* Pass through parent blocked state for 3p blocks

* Better translation

---------

Co-authored-by: Josh <hi@oracularhades.com>
Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
zio/stable
Eric Bailey 2024-06-18 18:03:23 -05:00 committed by GitHub
parent 2237e10ad2
commit ac08c76168
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 20 deletions

View File

@ -78,6 +78,7 @@ export interface FeedPostSliceItem {
feedContext: string | undefined feedContext: string | undefined
moderation: ModerationDecision moderation: ModerationDecision
parentAuthor?: AppBskyActorDefs.ProfileViewBasic parentAuthor?: AppBskyActorDefs.ProfileViewBasic
isParentBlocked?: boolean
} }
export interface FeedPostSlice { export interface FeedPostSlice {
@ -311,6 +312,10 @@ export function usePostFeedQuery(
const parentAuthor = const parentAuthor =
item.reply?.parent?.author ?? item.reply?.parent?.author ??
slice.items[i + 1]?.reply?.grandparentAuthor slice.items[i + 1]?.reply?.grandparentAuthor
const replyRef = item.reply
const isParentBlocked = AppBskyFeedDefs.isBlockedPost(
replyRef?.parent,
)
return { return {
_reactKey: `${slice._reactKey}-${i}-${item.post.uri}`, _reactKey: `${slice._reactKey}-${i}-${item.post.uri}`,
@ -324,6 +329,7 @@ export function usePostFeedQuery(
feedContext: item.feedContext || slice.feedContext, feedContext: item.feedContext || slice.feedContext,
moderation: moderations[i], moderation: moderations[i],
parentAuthor, parentAuthor,
isParentBlocked,
} }
} }
return undefined return undefined

View File

@ -56,6 +56,7 @@ interface FeedItemProps {
isThreadParent?: boolean isThreadParent?: boolean
feedContext: string | undefined feedContext: string | undefined
hideTopBorder?: boolean hideTopBorder?: boolean
isParentBlocked?: boolean
} }
export function FeedItem({ export function FeedItem({
@ -70,6 +71,7 @@ export function FeedItem({
isThreadLastChild, isThreadLastChild,
isThreadParent, isThreadParent,
hideTopBorder, hideTopBorder,
isParentBlocked,
}: FeedItemProps & {post: AppBskyFeedDefs.PostView}): React.ReactNode { }: FeedItemProps & {post: AppBskyFeedDefs.PostView}): React.ReactNode {
const postShadowed = usePostShadow(post) const postShadowed = usePostShadow(post)
const richText = useMemo( const richText = useMemo(
@ -100,6 +102,7 @@ export function FeedItem({
isThreadLastChild={isThreadLastChild} isThreadLastChild={isThreadLastChild}
isThreadParent={isThreadParent} isThreadParent={isThreadParent}
hideTopBorder={hideTopBorder} hideTopBorder={hideTopBorder}
isParentBlocked={isParentBlocked}
/> />
) )
} }
@ -119,6 +122,7 @@ let FeedItemInner = ({
isThreadLastChild, isThreadLastChild,
isThreadParent, isThreadParent,
hideTopBorder, hideTopBorder,
isParentBlocked,
}: FeedItemProps & { }: FeedItemProps & {
richText: RichTextAPI richText: RichTextAPI
post: Shadow<AppBskyFeedDefs.PostView> post: Shadow<AppBskyFeedDefs.PostView>
@ -320,7 +324,7 @@ let FeedItemInner = ({
onOpenAuthor={onOpenAuthor} onOpenAuthor={onOpenAuthor}
/> />
{!isThreadChild && showReplyTo && parentAuthor && ( {!isThreadChild && showReplyTo && parentAuthor && (
<ReplyToLabel profile={parentAuthor} /> <ReplyToLabel blocked={isParentBlocked} profile={parentAuthor} />
)} )}
<LabelsOnMyPost post={post} /> <LabelsOnMyPost post={post} />
<PostContent <PostContent
@ -409,9 +413,14 @@ let PostContent = ({
} }
PostContent = memo(PostContent) PostContent = memo(PostContent)
function ReplyToLabel({profile}: {profile: AppBskyActorDefs.ProfileViewBasic}) { function ReplyToLabel({
profile,
blocked,
}: {
profile: AppBskyActorDefs.ProfileViewBasic
blocked?: boolean
}) {
const pal = usePalette('default') const pal = usePalette('default')
return ( return (
<View style={[s.flexRow, s.mb2, s.alignCenter]}> <View style={[s.flexRow, s.mb2, s.alignCenter]}>
<FontAwesomeIcon <FontAwesomeIcon
@ -424,6 +433,9 @@ function ReplyToLabel({profile}: {profile: AppBskyActorDefs.ProfileViewBasic}) {
style={[pal.textLight, s.mr2]} style={[pal.textLight, s.mr2]}
lineHeight={1.2} lineHeight={1.2}
numberOfLines={1}> numberOfLines={1}>
{blocked ? (
<Trans context="description">Reply to a blocked post</Trans>
) : (
<Trans context="description"> <Trans context="description">
Reply to{' '} Reply to{' '}
<ProfileHoverCard inline did={profile.did}> <ProfileHoverCard inline did={profile.did}>
@ -441,6 +453,7 @@ function ReplyToLabel({profile}: {profile: AppBskyActorDefs.ProfileViewBasic}) {
/> />
</ProfileHoverCard> </ProfileHoverCard>
</Trans> </Trans>
)}
</Text> </Text>
</View> </View>
) )

View File

@ -34,6 +34,7 @@ let FeedSlice = ({
isThreadParent={isThreadParentAt(slice.items, 0)} isThreadParent={isThreadParentAt(slice.items, 0)}
isThreadChild={isThreadChildAt(slice.items, 0)} isThreadChild={isThreadChildAt(slice.items, 0)}
hideTopBorder={hideTopBorder} hideTopBorder={hideTopBorder}
isParentBlocked={slice.items[0].isParentBlocked}
/> />
<FeedItem <FeedItem
key={slice.items[1]._reactKey} key={slice.items[1]._reactKey}
@ -46,6 +47,7 @@ let FeedSlice = ({
moderation={slice.items[1].moderation} moderation={slice.items[1].moderation}
isThreadParent={isThreadParentAt(slice.items, 1)} isThreadParent={isThreadParentAt(slice.items, 1)}
isThreadChild={isThreadChildAt(slice.items, 1)} isThreadChild={isThreadChildAt(slice.items, 1)}
isParentBlocked={slice.items[1].isParentBlocked}
/> />
<ViewFullThread slice={slice} /> <ViewFullThread slice={slice} />
<FeedItem <FeedItem
@ -59,6 +61,7 @@ let FeedSlice = ({
moderation={slice.items[last].moderation} moderation={slice.items[last].moderation}
isThreadParent={isThreadParentAt(slice.items, last)} isThreadParent={isThreadParentAt(slice.items, last)}
isThreadChild={isThreadChildAt(slice.items, last)} isThreadChild={isThreadChildAt(slice.items, last)}
isParentBlocked={slice.items[2].isParentBlocked}
isThreadLastChild isThreadLastChild
/> />
</> </>
@ -82,6 +85,7 @@ let FeedSlice = ({
isThreadLastChild={ isThreadLastChild={
isThreadChildAt(slice.items, i) && slice.items.length === i + 1 isThreadChildAt(slice.items, i) && slice.items.length === i + 1
} }
isParentBlocked={slice.items[i].isParentBlocked}
hideTopBorder={hideTopBorder && i === 0} hideTopBorder={hideTopBorder && i === 0}
/> />
))} ))}