From 24f8794d4db517540a2151440deb51bba171f89a Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 20 May 2024 17:18:56 +0100 Subject: [PATCH] =?UTF-8?q?[=F0=9F=90=B4]=20DM=20button=20on=20profile=20(?= =?UTF-8?q?#4097)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add profile button * separate out button to component * normalise subscribe to labeller button size * infinite staletime * use Link rather than Button and change icon * adjust icon position --- src/components/dms/MessageProfileButton.tsx | 39 +++++++++++++ .../Profile/Header/ProfileHeaderLabeler.tsx | 6 +- .../Profile/Header/ProfileHeaderStandard.tsx | 56 ++++++++++++------- .../queries/messages/get-convo-for-members.ts | 32 ++++++++++- src/view/com/profile/ProfileMenu.tsx | 34 +++++------ 5 files changed, 125 insertions(+), 42 deletions(-) create mode 100644 src/components/dms/MessageProfileButton.tsx diff --git a/src/components/dms/MessageProfileButton.tsx b/src/components/dms/MessageProfileButton.tsx new file mode 100644 index 00000000..6f227de6 --- /dev/null +++ b/src/components/dms/MessageProfileButton.tsx @@ -0,0 +1,39 @@ +import React from 'react' +import {AppBskyActorDefs} from '@atproto/api' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {useMaybeConvoForUser} from '#/state/queries/messages/get-convo-for-members' +import {atoms as a, useTheme} from '#/alf' +import {Message_Stroke2_Corner0_Rounded as Message} from '../icons/Message' +import {Link} from '../Link' + +export function MessageProfileButton({ + profile, +}: { + profile: AppBskyActorDefs.ProfileView +}) { + const {_} = useLingui() + const t = useTheme() + + const {data: convoId} = useMaybeConvoForUser(profile.did) + + if (!convoId) return null + + return ( + + + + ) +} diff --git a/src/screens/Profile/Header/ProfileHeaderLabeler.tsx b/src/screens/Profile/Header/ProfileHeaderLabeler.tsx index 459bd0d9..e79b345c 100644 --- a/src/screens/Profile/Header/ProfileHeaderLabeler.tsx +++ b/src/screens/Profile/Header/ProfileHeaderLabeler.tsx @@ -128,7 +128,7 @@ let ProfileHeaderLabeler = ({ const onPressSubscribe = React.useCallback( () => - requireAuth(async () => { + requireAuth(async (): Promise => { if (!canSubscribe) { cantSubscribePrompt.open() return @@ -197,7 +197,6 @@ let ProfileHeaderLabeler = ({ diff --git a/src/screens/Profile/Header/ProfileHeaderStandard.tsx b/src/screens/Profile/Header/ProfileHeaderStandard.tsx index f3f2a370..66141e78 100644 --- a/src/screens/Profile/Header/ProfileHeaderStandard.tsx +++ b/src/screens/Profile/Header/ProfileHeaderStandard.tsx @@ -28,6 +28,7 @@ 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 {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import * as Prompt from '#/components/Prompt' @@ -156,7 +157,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}}> + + + )}