Update appearance of chat when blocked (#10582)
This commit is contained in:
@@ -1,38 +1,37 @@
|
|||||||
import {useCallback, useMemo} from 'react'
|
import {useCallback, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {LinearGradient} from 'expo-linear-gradient'
|
||||||
import {type ModerationDecision} from '@atproto/api'
|
import {type ModerationDecision} from '@atproto/api'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {Trans} from '@lingui/react/macro'
|
|
||||||
|
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {useProfileBlockMutationQueue} from '#/state/queries/profile'
|
import {useProfileBlockMutationQueue} from '#/state/queries/profile'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
import {Divider} from '#/components/Divider'
|
|
||||||
import {BlockedByListDialog} from '#/components/dms/BlockedByListDialog'
|
import {BlockedByListDialog} from '#/components/dms/BlockedByListDialog'
|
||||||
import {LeaveConvoPrompt} from '#/components/dms/LeaveConvoPrompt'
|
import {LeaveConvoPrompt} from '#/components/dms/LeaveConvoPrompt'
|
||||||
import {ReportConversationPrompt} from '#/components/dms/ReportConversationPrompt'
|
import {ReportConversationPrompt} from '#/components/dms/ReportConversationPrompt'
|
||||||
|
import {ArrowBoxLeft_Stroke2_Corner0_Rounded as LeaveIcon} from '#/components/icons/ArrowBoxLeft'
|
||||||
|
import {Flag_Stroke2_Corner0_Rounded as FlagIcon} from '#/components/icons/Flag'
|
||||||
|
import {PersonCheck_Stroke2_Corner0_Rounded as PersonCheckIcon} from '#/components/icons/Person'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function MessagesListBlockedFooter({
|
export function MessagesListBlockedFooter({
|
||||||
recipient: initialRecipient,
|
recipient: initialRecipient,
|
||||||
convoId,
|
convoId,
|
||||||
hasMessages,
|
|
||||||
moderation,
|
moderation,
|
||||||
}: {
|
}: {
|
||||||
recipient: bsky.profile.AnyProfileView
|
recipient: bsky.profile.AnyProfileView
|
||||||
convoId: string
|
convoId: string
|
||||||
hasMessages: boolean
|
|
||||||
moderation: ModerationDecision
|
moderation: ModerationDecision
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {_} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const recipient = useProfileShadow(initialRecipient)
|
const recipient = useProfileShadow(initialRecipient)
|
||||||
const [__, queueUnblock] = useProfileBlockMutationQueue(recipient)
|
const [_queueBlock, queueUnblock] = useProfileBlockMutationQueue(recipient)
|
||||||
|
|
||||||
const leaveConvoControl = useDialogControl()
|
const leaveConvoControl = useDialogControl()
|
||||||
const reportControl = useDialogControl()
|
const reportControl = useDialogControl()
|
||||||
@@ -55,82 +54,78 @@ export function MessagesListBlockedFooter({
|
|||||||
if (listBlocks.length) {
|
if (listBlocks.length) {
|
||||||
blockedByListControl.open()
|
blockedByListControl.open()
|
||||||
} else {
|
} else {
|
||||||
queueUnblock()
|
void queueUnblock()
|
||||||
}
|
}
|
||||||
}, [blockedByListControl, listBlocks, queueUnblock])
|
}, [blockedByListControl, listBlocks, queueUnblock])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[hasMessages && a.pt_md, a.pb_xl, a.gap_lg]}>
|
<View style={[a.gap_lg, a.p_2xl, t.atoms.bg]}>
|
||||||
<Divider />
|
<LinearGradient
|
||||||
<Text style={[a.text_md, a.font_semi_bold, a.text_center]}>
|
colors={['rgba(0,0,0,0)', 'rgba(0,0,0,0.08)']}
|
||||||
{isBlocking ? (
|
style={[a.absolute, {top: -16, left: 0, right: 0, height: 16}]}
|
||||||
<Trans>You have blocked this user</Trans>
|
pointerEvents="none"
|
||||||
) : (
|
/>
|
||||||
<Trans>This user has blocked you</Trans>
|
<Text style={[a.text_lg, a.font_semi_bold, a.text_center]}>
|
||||||
)}
|
{isBlocking
|
||||||
|
? l`You are blocking this user`
|
||||||
|
: l`This user is blocking you`}
|
||||||
</Text>
|
</Text>
|
||||||
|
<View style={[a.flex_row, a.justify_between, a.gap_md]}>
|
||||||
<View style={[a.flex_row, a.justify_between, a.gap_lg, a.px_md]}>
|
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Leave chat`)}
|
label={l`Report chat`}
|
||||||
color="secondary"
|
color="negative_subtle"
|
||||||
variant="solid"
|
size="large"
|
||||||
size="small"
|
|
||||||
style={[a.flex_1]}
|
style={[a.flex_1]}
|
||||||
onPress={leaveConvoControl.open}>
|
onPress={reportControl.open}>
|
||||||
<ButtonText style={{color: t.palette.negative_500}}>
|
<ButtonIcon icon={FlagIcon} />
|
||||||
<Trans>Leave chat</Trans>
|
<ButtonText>
|
||||||
|
<Trans>Report chat</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Report`)}
|
label={l`Delete chat`}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
variant="solid"
|
size="large"
|
||||||
size="small"
|
|
||||||
style={[a.flex_1]}
|
style={[a.flex_1]}
|
||||||
onPress={reportControl.open}>
|
onPress={leaveConvoControl.open}>
|
||||||
<ButtonText style={{color: t.palette.negative_500}}>
|
<ButtonIcon icon={LeaveIcon} />
|
||||||
<Trans>Report</Trans>
|
<ButtonText>
|
||||||
|
<Trans>Delete chat</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
{isBlocking && gtMobile && (
|
{isBlocking && gtMobile && (
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Unblock`)}
|
label={l`Unblock user`}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
variant="solid"
|
size="large"
|
||||||
size="small"
|
|
||||||
style={[a.flex_1]}
|
style={[a.flex_1]}
|
||||||
onPress={onUnblockPress}>
|
onPress={onUnblockPress}>
|
||||||
<ButtonText style={{color: t.palette.primary_500}}>
|
<ButtonIcon icon={PersonCheckIcon} />
|
||||||
<Trans>Unblock</Trans>
|
<ButtonText>
|
||||||
|
<Trans>Unblock user</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
{isBlocking && !gtMobile && (
|
{isBlocking && !gtMobile && (
|
||||||
<View style={[a.flex_row, a.justify_center, a.px_md]}>
|
<Button
|
||||||
<Button
|
label={l`Unblock user`}
|
||||||
label={_(msg`Unblock`)}
|
color="secondary"
|
||||||
color="secondary"
|
size="large"
|
||||||
variant="solid"
|
style={[a.flex_1]}
|
||||||
size="small"
|
onPress={onUnblockPress}>
|
||||||
style={[a.flex_1]}
|
<ButtonIcon icon={PersonCheckIcon} />
|
||||||
onPress={onUnblockPress}>
|
<ButtonText>
|
||||||
<ButtonText style={{color: t.palette.primary_500}}>
|
<Trans>Unblock user</Trans>
|
||||||
<Trans>Unblock</Trans>
|
</ButtonText>
|
||||||
</ButtonText>
|
</Button>
|
||||||
</Button>
|
|
||||||
</View>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<LeaveConvoPrompt
|
<LeaveConvoPrompt
|
||||||
control={leaveConvoControl}
|
control={leaveConvoControl}
|
||||||
currentScreen="conversation"
|
currentScreen="conversation"
|
||||||
convoId={convoId}
|
convoId={convoId}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ReportConversationPrompt control={reportControl} />
|
<ReportConversationPrompt control={reportControl} />
|
||||||
|
|
||||||
<BlockedByListDialog
|
<BlockedByListDialog
|
||||||
control={blockedByListControl}
|
control={blockedByListControl}
|
||||||
listBlocks={listBlocks}
|
listBlocks={listBlocks}
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ function Inner({convoId}: {convoId: string}) {
|
|||||||
setHasScrolled={setHasScrolled}
|
setHasScrolled={setHasScrolled}
|
||||||
isActive={isConvoActive(convoState)}
|
isActive={isConvoActive(convoState)}
|
||||||
isDisabled={convoState.status === ConvoStatus.Disabled}
|
isDisabled={convoState.status === ConvoStatus.Disabled}
|
||||||
hasMessages={isConvoActive(convoState) && convoState.items.length > 0}
|
|
||||||
/>
|
/>
|
||||||
{!readyToShow && (
|
{!readyToShow && (
|
||||||
<View
|
<View
|
||||||
@@ -194,14 +193,12 @@ function InnerReady({
|
|||||||
convo,
|
convo,
|
||||||
isActive,
|
isActive,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
hasMessages,
|
|
||||||
}: {
|
}: {
|
||||||
hasScrolled: boolean
|
hasScrolled: boolean
|
||||||
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
||||||
convo: ConvoWithDetails | null
|
convo: ConvoWithDetails | null
|
||||||
isActive: boolean
|
isActive: boolean
|
||||||
isDisabled: boolean
|
isDisabled: boolean
|
||||||
hasMessages: boolean
|
|
||||||
}) {
|
}) {
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const {top: topInset} = useSafeAreaInsets()
|
const {top: topInset} = useSafeAreaInsets()
|
||||||
@@ -269,7 +266,6 @@ function InnerReady({
|
|||||||
<MessagesListBlockedFooter
|
<MessagesListBlockedFooter
|
||||||
recipient={primaryMember}
|
recipient={primaryMember}
|
||||||
convoId={convo.view.id}
|
convoId={convo.view.id}
|
||||||
hasMessages={hasMessages}
|
|
||||||
moderation={primaryMemberModeration}
|
moderation={primaryMemberModeration}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user