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
parent
2237e10ad2
commit
ac08c76168
|
@ -78,6 +78,7 @@ export interface FeedPostSliceItem {
|
|||
feedContext: string | undefined
|
||||
moderation: ModerationDecision
|
||||
parentAuthor?: AppBskyActorDefs.ProfileViewBasic
|
||||
isParentBlocked?: boolean
|
||||
}
|
||||
|
||||
export interface FeedPostSlice {
|
||||
|
@ -311,6 +312,10 @@ export function usePostFeedQuery(
|
|||
const parentAuthor =
|
||||
item.reply?.parent?.author ??
|
||||
slice.items[i + 1]?.reply?.grandparentAuthor
|
||||
const replyRef = item.reply
|
||||
const isParentBlocked = AppBskyFeedDefs.isBlockedPost(
|
||||
replyRef?.parent,
|
||||
)
|
||||
|
||||
return {
|
||||
_reactKey: `${slice._reactKey}-${i}-${item.post.uri}`,
|
||||
|
@ -324,6 +329,7 @@ export function usePostFeedQuery(
|
|||
feedContext: item.feedContext || slice.feedContext,
|
||||
moderation: moderations[i],
|
||||
parentAuthor,
|
||||
isParentBlocked,
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
|
|
|
@ -56,6 +56,7 @@ interface FeedItemProps {
|
|||
isThreadParent?: boolean
|
||||
feedContext: string | undefined
|
||||
hideTopBorder?: boolean
|
||||
isParentBlocked?: boolean
|
||||
}
|
||||
|
||||
export function FeedItem({
|
||||
|
@ -70,6 +71,7 @@ export function FeedItem({
|
|||
isThreadLastChild,
|
||||
isThreadParent,
|
||||
hideTopBorder,
|
||||
isParentBlocked,
|
||||
}: FeedItemProps & {post: AppBskyFeedDefs.PostView}): React.ReactNode {
|
||||
const postShadowed = usePostShadow(post)
|
||||
const richText = useMemo(
|
||||
|
@ -100,6 +102,7 @@ export function FeedItem({
|
|||
isThreadLastChild={isThreadLastChild}
|
||||
isThreadParent={isThreadParent}
|
||||
hideTopBorder={hideTopBorder}
|
||||
isParentBlocked={isParentBlocked}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -119,6 +122,7 @@ let FeedItemInner = ({
|
|||
isThreadLastChild,
|
||||
isThreadParent,
|
||||
hideTopBorder,
|
||||
isParentBlocked,
|
||||
}: FeedItemProps & {
|
||||
richText: RichTextAPI
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
|
@ -320,7 +324,7 @@ let FeedItemInner = ({
|
|||
onOpenAuthor={onOpenAuthor}
|
||||
/>
|
||||
{!isThreadChild && showReplyTo && parentAuthor && (
|
||||
<ReplyToLabel profile={parentAuthor} />
|
||||
<ReplyToLabel blocked={isParentBlocked} profile={parentAuthor} />
|
||||
)}
|
||||
<LabelsOnMyPost post={post} />
|
||||
<PostContent
|
||||
|
@ -409,9 +413,14 @@ let PostContent = ({
|
|||
}
|
||||
PostContent = memo(PostContent)
|
||||
|
||||
function ReplyToLabel({profile}: {profile: AppBskyActorDefs.ProfileViewBasic}) {
|
||||
function ReplyToLabel({
|
||||
profile,
|
||||
blocked,
|
||||
}: {
|
||||
profile: AppBskyActorDefs.ProfileViewBasic
|
||||
blocked?: boolean
|
||||
}) {
|
||||
const pal = usePalette('default')
|
||||
|
||||
return (
|
||||
<View style={[s.flexRow, s.mb2, s.alignCenter]}>
|
||||
<FontAwesomeIcon
|
||||
|
@ -424,23 +433,27 @@ function ReplyToLabel({profile}: {profile: AppBskyActorDefs.ProfileViewBasic}) {
|
|||
style={[pal.textLight, s.mr2]}
|
||||
lineHeight={1.2}
|
||||
numberOfLines={1}>
|
||||
<Trans context="description">
|
||||
Reply to{' '}
|
||||
<ProfileHoverCard inline did={profile.did}>
|
||||
<TextLinkOnWebOnly
|
||||
type="md"
|
||||
style={pal.textLight}
|
||||
lineHeight={1.2}
|
||||
numberOfLines={1}
|
||||
href={makeProfileLink(profile)}
|
||||
text={
|
||||
profile.displayName
|
||||
? sanitizeDisplayName(profile.displayName)
|
||||
: sanitizeHandle(profile.handle)
|
||||
}
|
||||
/>
|
||||
</ProfileHoverCard>
|
||||
</Trans>
|
||||
{blocked ? (
|
||||
<Trans context="description">Reply to a blocked post</Trans>
|
||||
) : (
|
||||
<Trans context="description">
|
||||
Reply to{' '}
|
||||
<ProfileHoverCard inline did={profile.did}>
|
||||
<TextLinkOnWebOnly
|
||||
type="md"
|
||||
style={pal.textLight}
|
||||
lineHeight={1.2}
|
||||
numberOfLines={1}
|
||||
href={makeProfileLink(profile)}
|
||||
text={
|
||||
profile.displayName
|
||||
? sanitizeDisplayName(profile.displayName)
|
||||
: sanitizeHandle(profile.handle)
|
||||
}
|
||||
/>
|
||||
</ProfileHoverCard>
|
||||
</Trans>
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
|
|
|
@ -34,6 +34,7 @@ let FeedSlice = ({
|
|||
isThreadParent={isThreadParentAt(slice.items, 0)}
|
||||
isThreadChild={isThreadChildAt(slice.items, 0)}
|
||||
hideTopBorder={hideTopBorder}
|
||||
isParentBlocked={slice.items[0].isParentBlocked}
|
||||
/>
|
||||
<FeedItem
|
||||
key={slice.items[1]._reactKey}
|
||||
|
@ -46,6 +47,7 @@ let FeedSlice = ({
|
|||
moderation={slice.items[1].moderation}
|
||||
isThreadParent={isThreadParentAt(slice.items, 1)}
|
||||
isThreadChild={isThreadChildAt(slice.items, 1)}
|
||||
isParentBlocked={slice.items[1].isParentBlocked}
|
||||
/>
|
||||
<ViewFullThread slice={slice} />
|
||||
<FeedItem
|
||||
|
@ -59,6 +61,7 @@ let FeedSlice = ({
|
|||
moderation={slice.items[last].moderation}
|
||||
isThreadParent={isThreadParentAt(slice.items, last)}
|
||||
isThreadChild={isThreadChildAt(slice.items, last)}
|
||||
isParentBlocked={slice.items[2].isParentBlocked}
|
||||
isThreadLastChild
|
||||
/>
|
||||
</>
|
||||
|
@ -82,6 +85,7 @@ let FeedSlice = ({
|
|||
isThreadLastChild={
|
||||
isThreadChildAt(slice.items, i) && slice.items.length === i + 1
|
||||
}
|
||||
isParentBlocked={slice.items[i].isParentBlocked}
|
||||
hideTopBorder={hideTopBorder && i === 0}
|
||||
/>
|
||||
))}
|
||||
|
|
Loading…
Reference in New Issue