Add list of mutual chats to block dialog (#10727)
Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import {memo, useCallback, useMemo} from 'react'
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
import {useNavigation} from '@react-navigation/native'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
@@ -46,6 +44,7 @@ import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus
|
||||
import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as Unmute} from '#/components/icons/Speaker'
|
||||
import {StarterPack} from '#/components/icons/StarterPack'
|
||||
import * as Menu from '#/components/Menu'
|
||||
import {BlockDialog} from '#/components/moderation/BlockDialog'
|
||||
import {
|
||||
ReportDialog,
|
||||
useReportDialogControl,
|
||||
@@ -72,7 +71,7 @@ let ProfileMenu = ({
|
||||
}): React.ReactNode => {
|
||||
const t = useTheme()
|
||||
const ax = useAnalytics()
|
||||
const {_} = useLingui()
|
||||
const {t: l} = useLingui()
|
||||
const {currentAccount, hasSession} = useSession()
|
||||
const {openModal} = useModalControls()
|
||||
const reportDialogControl = useReportDialogControl()
|
||||
@@ -116,7 +115,7 @@ let ProfileMenu = ({
|
||||
}, [currentAccount, profile])
|
||||
|
||||
const invalidateProfileQuery = useCallback(() => {
|
||||
queryClient.invalidateQueries({
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: profileQueryKey(profile.did),
|
||||
})
|
||||
}, [queryClient, profile.did])
|
||||
@@ -124,10 +123,10 @@ let ProfileMenu = ({
|
||||
const onPressAddToStarterPacks = useCallback(() => {
|
||||
ax.metric('profile:addToStarterPack', {})
|
||||
addToStarterPacksDialogControl.open()
|
||||
}, [addToStarterPacksDialogControl])
|
||||
}, [addToStarterPacksDialogControl, ax])
|
||||
|
||||
const onPressShare = useCallback(() => {
|
||||
shareUrl(toShareUrl(makeProfileLink(profile)))
|
||||
void shareUrl(toShareUrl(makeProfileLink(profile)))
|
||||
}, [profile])
|
||||
|
||||
const onPressAddRemoveLists = useCallback(() => {
|
||||
@@ -145,11 +144,12 @@ let ProfileMenu = ({
|
||||
if (profile.viewer?.muted) {
|
||||
try {
|
||||
await queueUnmute()
|
||||
Toast.show(_(msg({message: 'Account unmuted', context: 'toast'})))
|
||||
} catch (e: any) {
|
||||
Toast.show(l({message: 'Account unmuted', context: 'toast'}))
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
if (e?.name !== 'AbortError') {
|
||||
ax.logger.error('Failed to unmute account', {message: e})
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, {
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
@@ -157,27 +157,29 @@ let ProfileMenu = ({
|
||||
} else {
|
||||
try {
|
||||
await queueMute()
|
||||
Toast.show(_(msg({message: 'Account muted', context: 'toast'})))
|
||||
} catch (e: any) {
|
||||
Toast.show(l({message: 'Account muted', context: 'toast'}))
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
if (e?.name !== 'AbortError') {
|
||||
ax.logger.error('Failed to mute account', {message: e})
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, {
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [ax, profile.viewer?.muted, queueUnmute, _, queueMute])
|
||||
}, [ax, profile.viewer?.muted, queueUnmute, l, queueMute])
|
||||
|
||||
const blockAccount = useCallback(async () => {
|
||||
if (profile.viewer?.blocking) {
|
||||
try {
|
||||
await queueUnblock()
|
||||
Toast.show(_(msg({message: 'Account unblocked', context: 'toast'})))
|
||||
} catch (e: any) {
|
||||
Toast.show(l({message: 'Account unblocked', context: 'toast'}))
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
if (e?.name !== 'AbortError') {
|
||||
ax.logger.error('Failed to unblock account', {message: e})
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, {
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
@@ -185,56 +187,59 @@ let ProfileMenu = ({
|
||||
} else {
|
||||
try {
|
||||
await queueBlock()
|
||||
Toast.show(_(msg({message: 'Account blocked', context: 'toast'})))
|
||||
} catch (e: any) {
|
||||
Toast.show(l({message: 'Account blocked', context: 'toast'}))
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
if (e?.name !== 'AbortError') {
|
||||
ax.logger.error('Failed to block account', {message: e})
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, {
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [ax, profile.viewer?.blocking, _, queueUnblock, queueBlock])
|
||||
}, [ax, profile.viewer?.blocking, l, queueUnblock, queueBlock])
|
||||
|
||||
const onPressFollowAccount = useCallback(async () => {
|
||||
try {
|
||||
await queueFollow()
|
||||
Toast.show(_(msg({message: 'Account followed', context: 'toast'})))
|
||||
} catch (e: any) {
|
||||
Toast.show(l({message: 'Account followed', context: 'toast'}))
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
if (e?.name !== 'AbortError') {
|
||||
ax.logger.error('Failed to follow account', {message: e})
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, {
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [_, ax, queueFollow])
|
||||
}, [l, ax, queueFollow])
|
||||
|
||||
const onPressUnfollowAccount = useCallback(async () => {
|
||||
try {
|
||||
await queueUnfollow()
|
||||
Toast.show(_(msg({message: 'Account unfollowed', context: 'toast'})))
|
||||
} catch (e: any) {
|
||||
Toast.show(l({message: 'Account unfollowed', context: 'toast'}))
|
||||
} catch (err) {
|
||||
const e = err as Error
|
||||
if (e?.name !== 'AbortError') {
|
||||
ax.logger.error('Failed to unfollow account', {message: e})
|
||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), {
|
||||
Toast.show(l`There was an issue! ${e.toString()}`, {
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [_, ax, queueUnfollow])
|
||||
}, [l, ax, queueUnfollow])
|
||||
|
||||
const onPressReportAccount = useCallback(() => {
|
||||
reportDialogControl.open()
|
||||
}, [reportDialogControl])
|
||||
|
||||
const onPressShareATUri = useCallback(() => {
|
||||
shareText(`at://${profile.did}`)
|
||||
void shareText(`at://${profile.did}`)
|
||||
}, [profile.did])
|
||||
|
||||
const onPressShareDID = useCallback(() => {
|
||||
shareText(profile.did)
|
||||
void shareText(profile.did)
|
||||
}, [profile.did])
|
||||
|
||||
const onPressSearch = useCallback(() => {
|
||||
@@ -251,14 +256,14 @@ let ProfileMenu = ({
|
||||
return (
|
||||
<EventStopper onKeyDown={false}>
|
||||
<Menu.Root>
|
||||
<Menu.Trigger label={_(msg`More options`)}>
|
||||
<Menu.Trigger label={l`More options`}>
|
||||
{({props}) => {
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
{...props}
|
||||
testID="profileHeaderDropdownBtn"
|
||||
label={_(msg`More options`)}
|
||||
label={l`More options`}
|
||||
hitSlop={HITSLOP_20}
|
||||
variant="solid"
|
||||
color="secondary"
|
||||
@@ -267,7 +272,6 @@ let ProfileMenu = ({
|
||||
{statusNudgeActive && <Gradient style={[a.rounded_full]} />}
|
||||
<ButtonIcon icon={Ellipsis} size="sm" />
|
||||
</Button>
|
||||
|
||||
{statusNudgeActive && <Dot top={1} right={1} />}
|
||||
</>
|
||||
)
|
||||
@@ -278,9 +282,7 @@ let ProfileMenu = ({
|
||||
<Menu.Group>
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownShareBtn"
|
||||
label={
|
||||
IS_WEB ? _(msg`Copy link to profile`) : _(msg`Share via...`)
|
||||
}
|
||||
label={IS_WEB ? l`Copy link to profile` : l`Share via...`}
|
||||
onPress={() => {
|
||||
if (showLoggedOutWarning) {
|
||||
loggedOutWarningPromptControl.open()
|
||||
@@ -301,7 +303,7 @@ let ProfileMenu = ({
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownSearchBtn"
|
||||
label={_(msg`Search posts`)}
|
||||
label={l`Search posts`}
|
||||
onPress={onPressSearch}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Search posts</Trans>
|
||||
@@ -320,14 +322,12 @@ let ProfileMenu = ({
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownFollowBtn"
|
||||
label={
|
||||
isFollowing
|
||||
? _(msg`Unfollow account`)
|
||||
: _(msg`Follow account`)
|
||||
isFollowing ? l`Unfollow account` : l`Follow account`
|
||||
}
|
||||
onPress={
|
||||
isFollowing
|
||||
? onPressUnfollowAccount
|
||||
: onPressFollowAccount
|
||||
? () => void onPressUnfollowAccount()
|
||||
: () => void onPressFollowAccount()
|
||||
}>
|
||||
<Menu.ItemText>
|
||||
{isFollowing ? (
|
||||
@@ -343,7 +343,7 @@ let ProfileMenu = ({
|
||||
)}
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownStarterPackAddRemoveBtn"
|
||||
label={_(msg`Add to starter packs`)}
|
||||
label={l`Add to starter packs`}
|
||||
onPress={onPressAddToStarterPacks}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Add to starter packs</Trans>
|
||||
@@ -352,7 +352,7 @@ let ProfileMenu = ({
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownListAddRemoveBtn"
|
||||
label={_(msg`Add to lists`)}
|
||||
label={l`Add to lists`}
|
||||
onPress={onPressAddRemoveLists}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Add to lists</Trans>
|
||||
@@ -364,10 +364,10 @@ let ProfileMenu = ({
|
||||
testID="profileHeaderDropdownListAddRemoveBtn"
|
||||
label={
|
||||
status.isDisabled
|
||||
? _(msg`Go live (disabled)`)
|
||||
? l`Go live (disabled)`
|
||||
: status.isActive
|
||||
? _(msg`Edit live status`)
|
||||
: _(msg`Go live`)
|
||||
? l`Edit live status`
|
||||
: l`Go live`
|
||||
}
|
||||
onPress={() => {
|
||||
if (status.isDisabled) {
|
||||
@@ -418,7 +418,7 @@ let ProfileMenu = ({
|
||||
(verification.viewer.hasIssuedVerification ? (
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownVerificationRemoveButton"
|
||||
label={_(msg`Remove verification`)}
|
||||
label={l`Remove verification`}
|
||||
onPress={() => verificationRemovePromptControl.open()}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Remove verification</Trans>
|
||||
@@ -428,7 +428,7 @@ let ProfileMenu = ({
|
||||
) : (
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownVerificationCreateButton"
|
||||
label={_(msg`Verify account`)}
|
||||
label={l`Verify account`}
|
||||
onPress={() => verificationCreatePromptControl.open()}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Verify account</Trans>
|
||||
@@ -444,10 +444,10 @@ let ProfileMenu = ({
|
||||
testID="profileHeaderDropdownMuteBtn"
|
||||
label={
|
||||
profile.viewer?.muted
|
||||
? _(msg`Unmute account`)
|
||||
: _(msg`Mute account`)
|
||||
? l`Unmute account`
|
||||
: l`Mute account`
|
||||
}
|
||||
onPress={onPressMuteAccount}>
|
||||
onPress={() => void onPressMuteAccount()}>
|
||||
<Menu.ItemText>
|
||||
{profile.viewer?.muted ? (
|
||||
<Trans>Unmute account</Trans>
|
||||
@@ -464,9 +464,9 @@ let ProfileMenu = ({
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownBlockBtn"
|
||||
label={
|
||||
profile.viewer
|
||||
? _(msg`Unblock account`)
|
||||
: _(msg`Block account`)
|
||||
profile.viewer?.blocking
|
||||
? l`Unblock account`
|
||||
: l`Block account`
|
||||
}
|
||||
onPress={() => blockPromptControl.open()}>
|
||||
<Menu.ItemText>
|
||||
@@ -485,7 +485,7 @@ let ProfileMenu = ({
|
||||
)}
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownReportBtn"
|
||||
label={_(msg`Report account`)}
|
||||
label={l`Report account`}
|
||||
onPress={onPressReportAccount}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Report account</Trans>
|
||||
@@ -503,7 +503,7 @@ let ProfileMenu = ({
|
||||
<Menu.Group>
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownShareATURIBtn"
|
||||
label={_(msg`Copy at:// URI`)}
|
||||
label={l`Copy at:// URI`}
|
||||
onPress={onPressShareATUri}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Copy at:// URI</Trans>
|
||||
@@ -512,7 +512,7 @@ let ProfileMenu = ({
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
testID="profileHeaderDropdownShareDIDBtn"
|
||||
label={_(msg`Copy DID`)}
|
||||
label={l`Copy DID`}
|
||||
onPress={onPressShareDID}>
|
||||
<Menu.ItemText>
|
||||
<Trans>Copy DID</Trans>
|
||||
@@ -524,12 +524,10 @@ let ProfileMenu = ({
|
||||
) : null}
|
||||
</Menu.Outer>
|
||||
</Menu.Root>
|
||||
|
||||
<StarterPackDialog
|
||||
control={addToStarterPacksDialogControl}
|
||||
targetDid={profile.did}
|
||||
/>
|
||||
|
||||
<ReportDialog
|
||||
control={reportDialogControl}
|
||||
subject={{
|
||||
@@ -537,44 +535,18 @@ let ProfileMenu = ({
|
||||
$type: 'app.bsky.actor.defs#profileViewDetailed',
|
||||
}}
|
||||
/>
|
||||
|
||||
<Prompt.Basic
|
||||
<BlockDialog
|
||||
control={blockPromptControl}
|
||||
title={
|
||||
profile.viewer?.blocking
|
||||
? _(msg`Unblock Account?`)
|
||||
: _(msg`Block Account?`)
|
||||
}
|
||||
description={
|
||||
profile.viewer?.blocking
|
||||
? _(
|
||||
msg`The account will be able to interact with you after unblocking.`,
|
||||
)
|
||||
: profile.associated?.labeler
|
||||
? _(
|
||||
msg`Blocking will not prevent labels from being applied on your account, but it will stop this account from replying in your threads or interacting with you.`,
|
||||
)
|
||||
: _(
|
||||
msg`Blocked accounts cannot reply in your threads, mention you, or otherwise interact with you.`,
|
||||
)
|
||||
}
|
||||
onConfirm={blockAccount}
|
||||
confirmButtonCta={
|
||||
profile.viewer?.blocking ? _(msg`Unblock`) : _(msg`Block`)
|
||||
}
|
||||
confirmButtonColor={profile.viewer?.blocking ? undefined : 'negative'}
|
||||
profile={profile}
|
||||
onBlock={blockAccount}
|
||||
/>
|
||||
|
||||
<Prompt.Basic
|
||||
control={loggedOutWarningPromptControl}
|
||||
title={_(msg`Note about sharing`)}
|
||||
description={_(
|
||||
msg`This profile is only visible to logged-in users. It won't be visible to people who aren't signed in.`,
|
||||
)}
|
||||
title={l`Note about sharing`}
|
||||
description={l`This profile is only visible to logged-in users. It won't be visible to people who aren't signed in.`}
|
||||
onConfirm={onPressShare}
|
||||
confirmButtonCta={_(msg`Share anyway`)}
|
||||
confirmButtonCta={l`Share anyway`}
|
||||
/>
|
||||
|
||||
<VerificationCreatePrompt
|
||||
control={verificationCreatePromptControl}
|
||||
profile={profile}
|
||||
@@ -584,7 +556,6 @@ let ProfileMenu = ({
|
||||
profile={profile}
|
||||
verifications={currentAccountVerifications}
|
||||
/>
|
||||
|
||||
{status.isDisabled ? (
|
||||
<GoLiveDisabledDialog
|
||||
control={goLiveDisabledDialogControl}
|
||||
|
||||
Reference in New Issue
Block a user