Adds dismiss button to suggested user cards, behind a feature gate

This commit is contained in:
Alex Benzer
2025-12-04 16:01:37 -08:00
parent 931bcd63e3
commit dca2ec7404
3 changed files with 24 additions and 20 deletions
+21 -20
View File
@@ -7,7 +7,7 @@ import {useLingui} from '@lingui/react'
import {useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {type NavigationProp} from '#/lib/routes/types' import {type NavigationProp} from '#/lib/routes/types'
import {logEvent} from '#/lib/statsig/statsig' import {logEvent, useGate} from '#/lib/statsig/statsig'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isIOS} from '#/platform/detection' import {isIOS} from '#/platform/detection'
import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useModerationOpts} from '#/state/preferences/moderation-opts'
@@ -429,12 +429,14 @@ export function ProfileGrid({
}) { }) {
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const gate = useGate()
const moderationOpts = useModerationOpts() const moderationOpts = useModerationOpts()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const isLoading = isSuggestionsLoading || !moderationOpts const isLoading = isSuggestionsLoading || !moderationOpts
const isProfileHeaderContext = viewContext === 'profileHeader' const isProfileHeaderContext = viewContext === 'profileHeader'
const isFeedContext = viewContext === 'feed' const isFeedContext = viewContext === 'feed'
const showDismissButton = gate('suggested_users_dismiss') && onDismiss
const maxLength = gtMobile ? 3 : isProfileHeaderContext ? 12 : 6 const maxLength = gtMobile ? 3 : isProfileHeaderContext ? 12 : 6
const minLength = gtMobile ? 3 : 4 const minLength = gtMobile ? 3 : 4
@@ -494,40 +496,39 @@ export function ProfileGrid({
(hovered || pressed) && t.atoms.border_contrast_high, (hovered || pressed) && t.atoms.border_contrast_high,
]}> ]}>
<ProfileCard.Outer> <ProfileCard.Outer>
{onDismiss && ( {showDismissButton && (
<Button <Button
label={_(msg`Dismiss this suggestion`)} label={_(msg`Dismiss this suggestion`)}
onPress={e => { onPress={e => {
e.preventDefault() e.preventDefault()
onDismiss(profile.did) onDismiss!(profile.did)
logEvent('suggestedUser:dismiss', { logEvent('suggestedUser:dismiss', {
logContext: isFeedContext logContext: isFeedContext
? 'InterstitialDiscover' ? 'InterstitialDiscover'
: 'InterstitialProfile', : 'InterstitialProfile',
position: index, position: index,
suggestedDid: profile.did,
recId,
}) })
}} }}
hitSlop={6} style={[
style={[a.absolute, a.z_10, {top: -6, right: -6}]}> a.absolute,
a.z_10,
a.p_xs,
{top: -4, right: -4},
]}>
{({ {({
hovered: dismissHovered, hovered: dismissHovered,
pressed: dismissPressed, pressed: dismissPressed,
}) => ( }) => (
<View <X
style={[ size="xs"
a.justify_center, fill={
a.align_center, dismissHovered || dismissPressed
a.rounded_full, ? t.atoms.text.color
t.atoms.bg_contrast_50, : t.atoms.text_contrast_medium.color
{width: 20, height: 20}, }
(dismissHovered || dismissPressed) && />
t.atoms.bg_contrast_100,
]}>
<X
size="xs"
fill={t.atoms.text_contrast_medium.color}
/>
</View>
)} )}
</Button> </Button>
)} )}
+1
View File
@@ -9,5 +9,6 @@ export type Gate =
| 'onboarding_add_video_feed' | 'onboarding_add_video_feed'
| 'onboarding_suggested_starterpacks' | 'onboarding_suggested_starterpacks'
| 'remove_show_latest_button' | 'remove_show_latest_button'
| 'suggested_users_dismiss'
| 'test_gate_1' | 'test_gate_1'
| 'test_gate_2' | 'test_gate_2'
+2
View File
@@ -336,7 +336,9 @@ export type MetricEvents = {
} }
'suggestedUser:dismiss': { 'suggestedUser:dismiss': {
logContext: 'InterstitialDiscover' | 'InterstitialProfile' logContext: 'InterstitialDiscover' | 'InterstitialProfile'
recId?: number
position: number position: number
suggestedDid: string
} }
'profile:unfollow': { 'profile:unfollow': {
logContext: logContext: