From 31a716d256730a7c04e9f57e77f425c6d7dca75b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 20 May 2024 16:16:29 -0500 Subject: [PATCH] =?UTF-8?q?[=F0=9F=90=B4]=20Handle=20deleted=20accounts,?= =?UTF-8?q?=20restructure=20ChatListItem=20(#4114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Handle deleted accounts, restructure ChatListItem * Remove triggerOpacity option * account for handle change in screen reader * simplify the check --------- Co-authored-by: Hailey --- src/components/dms/ConvoMenu.tsx | 147 ++++++++------ src/screens/Messages/List/ChatListItem.tsx | 221 +++++++++++---------- 2 files changed, 202 insertions(+), 166 deletions(-) diff --git a/src/components/dms/ConvoMenu.tsx b/src/components/dms/ConvoMenu.tsx index 0e5cd12b..a3440067 100644 --- a/src/components/dms/ConvoMenu.tsx +++ b/src/components/dms/ConvoMenu.tsx @@ -18,7 +18,7 @@ import { import {useMuteConvo} from '#/state/queries/messages/mute-conversation' import {useProfileBlockMutationQueue} from '#/state/queries/profile' import * as Toast from '#/view/com/util/Toast' -import {atoms as a, useTheme} from '#/alf' +import {atoms as a, useTheme, ViewStyleProp} from '#/alf' import {BlockedByListDialog} from '#/components/dms/BlockedByListDialog' import {LeaveConvoPrompt} from '#/components/dms/LeaveConvoPrompt' import {ReportConversationPrompt} from '#/components/dms/ReportConversationPrompt' @@ -41,8 +41,8 @@ let ConvoMenu = ({ currentScreen, showMarkAsRead, hideTrigger, - triggerOpacity, blockInfo, + style, }: { convo: ChatBskyConvoDefs.ConvoView profile: Shadow @@ -50,11 +50,11 @@ let ConvoMenu = ({ currentScreen: 'list' | 'conversation' showMarkAsRead?: boolean hideTrigger?: boolean - triggerOpacity?: number blockInfo: { listBlocks: ModerationCause[] userBlock?: ModerationCause } + style?: ViewStyleProp['style'] }): React.ReactNode => { const navigation = useNavigation() const {_} = useLingui() @@ -66,6 +66,7 @@ let ConvoMenu = ({ const {listBlocks, userBlock} = blockInfo const isBlocking = userBlock || !!listBlocks.length + const isDeletedAccount = profile.handle === 'missing.invalid' const {data: convo} = useConvoQuery(initialConvo) @@ -105,7 +106,7 @@ let ConvoMenu = ({ <> {!hideTrigger && ( - + {({props, state}) => ( )} - - - {showMarkAsRead && ( - - markAsRead({ - convoId: convo?.id, - }) - }> - - Mark as read - - - - )} - - - Go to profile - - - - muteConvo({mute: !convo?.muted})}> - - {convo?.muted ? ( - Unmute conversation - ) : ( - Mute conversation - )} - - - - - - - - - {isBlocking ? _(msg`Unblock account`) : _(msg`Block account`)} - - - - - - Report conversation - - - - - - + + {isDeletedAccount ? ( + @@ -196,8 +140,79 @@ let ConvoMenu = ({ - - + + ) : ( + + + {showMarkAsRead && ( + + markAsRead({ + convoId: convo?.id, + }) + }> + + Mark as read + + + + )} + + + Go to profile + + + + muteConvo({mute: !convo?.muted})}> + + {convo?.muted ? ( + Unmute conversation + ) : ( + Mute conversation + )} + + + + + + + + + {isBlocking ? _(msg`Unblock account`) : _(msg`Block account`)} + + + + + + Report conversation + + + + + + + + + Leave conversation + + + + + + )} () const [showActions, setShowActions] = useState(false) const onMouseEnter = useCallback(() => { @@ -121,12 +120,6 @@ function ChatListItemReady({ setShowActions(true) }, []) - const onPress = useCallback(() => { - navigation.push('MessagesConversation', { - conversation: convo.id, - }) - }, [convo.id, navigation]) - const onLongPress = useCallback(() => { menuControl.open() }, [menuControl]) @@ -137,13 +130,16 @@ function ChatListItemReady({ onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} onFocus={onFocus} - onBlur={onMouseLeave}> - + + + 0} + hideTrigger={isNative} + blockInfo={blockInfo} + style={[ + a.absolute, + a.h_full, + a.self_end, + a.justify_center, + { + right: a.px_lg.paddingRight, + opacity: !gtMobile || showActions || menuControl.isOpen ? 1 : 0, + }, + ]} + /> ) }