From 7496540d07caa6e8f1dc803d33e892856da07de7 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Sat, 18 May 2024 20:57:01 +0100 Subject: [PATCH 1/6] add profile button --- .../Profile/Header/ProfileHeaderStandard.tsx | 79 ++++++++++++++----- .../queries/messages/get-convo-for-members.ts | 30 ++++++- src/view/com/profile/ProfileMenu.tsx | 34 ++++---- 3 files changed, 104 insertions(+), 39 deletions(-) diff --git a/src/screens/Profile/Header/ProfileHeaderStandard.tsx b/src/screens/Profile/Header/ProfileHeaderStandard.tsx index f3f2a370da..953fbd6169 100644 --- a/src/screens/Profile/Header/ProfileHeaderStandard.tsx +++ b/src/screens/Profile/Header/ProfileHeaderStandard.tsx @@ -9,12 +9,15 @@ import { import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useNavigation} from '@react-navigation/native' +import {NavigationProp} from '#/lib/routes/types' import {useGate} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {isIOS, isWeb} from '#/platform/detection' import {Shadow} from '#/state/cache/types' import {useModalControls} from '#/state/modals' +import {useMaybeConvoForUser} from '#/state/queries/messages/get-convo-for-members' import { useProfileBlockMutationQueue, useProfileFollowMutationQueue, @@ -29,6 +32,7 @@ import * as Toast from '#/view/com/util/Toast' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' +import {Envelope_Stroke2_Corner0_Rounded as Envelope} from '#/components/icons/Envelope' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import * as Prompt from '#/components/Prompt' import {RichText} from '#/components/RichText' @@ -71,6 +75,9 @@ let ProfileHeaderStandard = ({ const [_queueBlock, queueUnblock] = useProfileBlockMutationQueue(profile) const unblockPromptControl = Prompt.usePromptControl() const requireAuth = useRequireAuth() + const navigation = useNavigation() + + const {data: convoId} = useMaybeConvoForUser(profile.did) const onPressEditProfile = React.useCallback(() => { track('ProfileHeader:EditProfileButtonClicked') @@ -141,6 +148,11 @@ let ProfileHeaderStandard = ({ } }, [_, queueUnblock, track]) + const onPressDm = React.useCallback(() => { + if (!convoId) return + navigation.navigate('MessagesConversation', {conversation: convoId}) + }, [navigation, convoId]) + const isMe = React.useMemo( () => currentAccount?.did === profile.did, [currentAccount, profile], @@ -156,7 +168,14 @@ let ProfileHeaderStandard = ({ style={[a.px_lg, a.pt_md, a.pb_sm]} pointerEvents={isIOS ? 'auto' : 'box-none'}> {isMe ? ( + )} + + label={_(msg`Show follows similar to ${profile.handle}`)} + style={{width: 36, height: 36}}> + + + )} + ) +} diff --git a/src/screens/Profile/Header/ProfileHeaderStandard.tsx b/src/screens/Profile/Header/ProfileHeaderStandard.tsx index 953fbd6169..66141e7826 100644 --- a/src/screens/Profile/Header/ProfileHeaderStandard.tsx +++ b/src/screens/Profile/Header/ProfileHeaderStandard.tsx @@ -9,15 +9,12 @@ import { import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useNavigation} from '@react-navigation/native' -import {NavigationProp} from '#/lib/routes/types' import {useGate} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {isIOS, isWeb} from '#/platform/detection' import {Shadow} from '#/state/cache/types' import {useModalControls} from '#/state/modals' -import {useMaybeConvoForUser} from '#/state/queries/messages/get-convo-for-members' import { useProfileBlockMutationQueue, useProfileFollowMutationQueue, @@ -31,8 +28,8 @@ import {ProfileMenu} from '#/view/com/profile/ProfileMenu' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {MessageProfileButton} from '#/components/dms/MessageProfileButton' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' -import {Envelope_Stroke2_Corner0_Rounded as Envelope} from '#/components/icons/Envelope' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import * as Prompt from '#/components/Prompt' import {RichText} from '#/components/RichText' @@ -75,9 +72,6 @@ let ProfileHeaderStandard = ({ const [_queueBlock, queueUnblock] = useProfileBlockMutationQueue(profile) const unblockPromptControl = Prompt.usePromptControl() const requireAuth = useRequireAuth() - const navigation = useNavigation() - - const {data: convoId} = useMaybeConvoForUser(profile.did) const onPressEditProfile = React.useCallback(() => { track('ProfileHeader:EditProfileButtonClicked') @@ -148,11 +142,6 @@ let ProfileHeaderStandard = ({ } }, [_, queueUnblock, track]) - const onPressDm = React.useCallback(() => { - if (!convoId) return - navigation.navigate('MessagesConversation', {conversation: convoId}) - }, [navigation, convoId]) - const isMe = React.useMemo( () => currentAccount?.did === profile.did, [currentAccount, profile], @@ -210,19 +199,7 @@ let ProfileHeaderStandard = ({ <> {hasSession && ( <> - {convoId && ( - - )} + + to={`/messages/${convoId}`} + style={[a.justify_center, {width: 36, height: 36}]}> + + ) } From 0d5633a7730a675f9c4d84e3885a52be895b385e Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 20 May 2024 17:09:19 +0100 Subject: [PATCH 6/6] adjust icon position --- src/components/dms/MessageProfileButton.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/dms/MessageProfileButton.tsx b/src/components/dms/MessageProfileButton.tsx index 7c0c5612fd..6f227de65a 100644 --- a/src/components/dms/MessageProfileButton.tsx +++ b/src/components/dms/MessageProfileButton.tsx @@ -30,7 +30,10 @@ export function MessageProfileButton({ label={_(msg`Message ${profile.handle}`)} to={`/messages/${convoId}`} style={[a.justify_center, {width: 36, height: 36}]}> - + ) }