diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/KnownFollowers.tsx | 67 | ||||
-rw-r--r-- | src/components/NewskieDialog.tsx | 10 | ||||
-rw-r--r-- | src/components/ProfileHoverCard/index.web.tsx | 2 | ||||
-rw-r--r-- | src/components/moderation/PostAlerts.tsx | 2 | ||||
-rw-r--r-- | src/components/moderation/PostHider.tsx | 12 |
5 files changed, 69 insertions, 24 deletions
diff --git a/src/components/KnownFollowers.tsx b/src/components/KnownFollowers.tsx index 63f61ce85..7b861dc66 100644 --- a/src/components/KnownFollowers.tsx +++ b/src/components/KnownFollowers.tsx @@ -100,7 +100,15 @@ function KnownFollowersInner({ moderation, } }) - const count = cachedKnownFollowers.count + + // Does not have blocks applied. Always >= slices.length + const serverCount = cachedKnownFollowers.count + + /* + * We check above too, but here for clarity and a reminder to _check for + * valid indices_ + */ + if (slice.length === 0) return null return ( <Link @@ -164,31 +172,54 @@ function KnownFollowersInner({ }, ]} numberOfLines={2}> - {count > 2 ? ( - <Trans> - Followed by{' '} - <Text key={slice[0].profile.did} style={textStyle}> - {slice[0].profile.displayName} - </Text> - ,{' '} - <Text key={slice[1].profile.did} style={textStyle}> - {slice[1].profile.displayName} - </Text> - , and{' '} - <Plural value={count - 2} one="# other" other="# others" /> - </Trans> - ) : count === 2 ? ( + {slice.length >= 2 ? ( + // 2-n followers, including blocks + serverCount > 2 ? ( + <Trans> + Followed by{' '} + <Text key={slice[0].profile.did} style={textStyle}> + {slice[0].profile.displayName} + </Text> + ,{' '} + <Text key={slice[1].profile.did} style={textStyle}> + {slice[1].profile.displayName} + </Text> + , and{' '} + <Plural + value={serverCount - 2} + one="# other" + other="# others" + /> + </Trans> + ) : ( + // only 2 + <Trans> + Followed by{' '} + <Text key={slice[0].profile.did} style={textStyle}> + {slice[0].profile.displayName} + </Text>{' '} + and{' '} + <Text key={slice[1].profile.did} style={textStyle}> + {slice[1].profile.displayName} + </Text> + </Trans> + ) + ) : serverCount > 1 ? ( + // 1-n followers, including blocks <Trans> Followed by{' '} <Text key={slice[0].profile.did} style={textStyle}> {slice[0].profile.displayName} </Text>{' '} and{' '} - <Text key={slice[1].profile.did} style={textStyle}> - {slice[1].profile.displayName} - </Text> + <Plural + value={serverCount - 1} + one="# other" + other="# others" + /> </Trans> ) : ( + // only 1 <Trans> Followed by{' '} <Text key={slice[0].profile.did} style={textStyle}> diff --git a/src/components/NewskieDialog.tsx b/src/components/NewskieDialog.tsx index fcdae0daa..0354bfc43 100644 --- a/src/components/NewskieDialog.tsx +++ b/src/components/NewskieDialog.tsx @@ -18,8 +18,10 @@ import {Text} from '#/components/Typography' export function NewskieDialog({ profile, + disabled, }: { profile: AppBskyActorDefs.ProfileViewDetailed + disabled?: boolean }) { const {_} = useLingui() const moderationOpts = useModerationOpts() @@ -30,18 +32,20 @@ export function NewskieDialog({ const moderation = moderateProfile(profile, moderationOpts) return sanitizeDisplayName(name, moderation.ui('displayName')) }, [moderationOpts, profile]) + const [now] = React.useState(() => Date.now()) const timeAgo = useGetTimeAgo() const createdAt = profile.createdAt as string | undefined const daysOld = React.useMemo(() => { if (!createdAt) return Infinity - return differenceInSeconds(new Date(), new Date(createdAt)) / 86400 - }, [createdAt]) + return differenceInSeconds(now, new Date(createdAt)) / 86400 + }, [createdAt, now]) if (!createdAt || daysOld > 7) return null return ( <View style={[a.pr_2xs]}> <Button + disabled={disabled} label={_( msg`This user is new here. Press for more info about when they joined.`, )} @@ -70,7 +74,7 @@ export function NewskieDialog({ <Text style={[a.text_md]}> <Trans> {profileName} joined Bluesky{' '} - {timeAgo(createdAt, {format: 'long'})} ago + {timeAgo(createdAt, now, {format: 'long'})} ago </Trans> </Text> </View> diff --git a/src/components/ProfileHoverCard/index.web.tsx b/src/components/ProfileHoverCard/index.web.tsx index 4f110485e..319eccfa4 100644 --- a/src/components/ProfileHoverCard/index.web.tsx +++ b/src/components/ProfileHoverCard/index.web.tsx @@ -469,7 +469,7 @@ function Inner({ )} </Text> - <ProfileHeaderHandle profile={profileShadow} /> + <ProfileHeaderHandle profile={profileShadow} disableTaps /> </View> </Link> diff --git a/src/components/moderation/PostAlerts.tsx b/src/components/moderation/PostAlerts.tsx index 0b48b51d1..ec7529a4f 100644 --- a/src/components/moderation/PostAlerts.tsx +++ b/src/components/moderation/PostAlerts.tsx @@ -92,6 +92,8 @@ function PostLabel({ <UserAvatar avatar={desc.sourceAvi} size={size === 'large' ? 16 : 12} + type="labeler" + shape="circle" /> ) : ( <desc.icon size="sm" fill={t.atoms.text_contrast_medium.color} /> diff --git a/src/components/moderation/PostHider.tsx b/src/components/moderation/PostHider.tsx index 8a6474297..b6fb17452 100644 --- a/src/components/moderation/PostHider.tsx +++ b/src/components/moderation/PostHider.tsx @@ -1,6 +1,6 @@ import React, {ComponentProps} from 'react' import {Pressable, StyleProp, StyleSheet, View, ViewStyle} from 'react-native' -import {AppBskyActorDefs, ModerationUI} from '@atproto/api' +import {AppBskyActorDefs, ModerationCause, ModerationUI} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' @@ -45,7 +45,8 @@ export function PostHider({ const [override, setOverride] = React.useState(false) const control = useModerationDetailsDialogControl() const blur = - modui.blurs[0] || (interpretFilterAsBlur ? modui.filters[0] : undefined) + modui.blurs[0] || + (interpretFilterAsBlur ? getBlurrableFilter(modui) : undefined) const desc = useModerationCauseDescription(blur) const onBeforePress = React.useCallback(() => { @@ -134,6 +135,13 @@ export function PostHider({ ) } +function getBlurrableFilter(modui: ModerationUI): ModerationCause | undefined { + // moderation causes get "downgraded" when they originate from embedded content + // a downgraded cause should *only* drive filtering in feeds, so we want to look + // for filters that arent downgraded + return modui.filters.find(filter => !filter.downgraded) +} + const styles = StyleSheet.create({ child: { borderWidth: 0, |