From 99078bbff2282ad18594a4d5a4ed5fe207c394e4 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 12 Jun 2024 08:51:08 -0700 Subject: [PATCH] Don't show warning when sharing your own post in PWI opt-out mode (#4495) --- src/view/com/profile/ProfileMenu.tsx | 7 +++++-- src/view/com/util/forms/PostDropdownBtn.tsx | 5 ++++- src/view/com/util/post-ctrls/PostCtrls.tsx | 10 ++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/view/com/profile/ProfileMenu.tsx b/src/view/com/profile/ProfileMenu.tsx index 5d39e5f0..efc24976 100644 --- a/src/view/com/profile/ProfileMenu.tsx +++ b/src/view/com/profile/ProfileMenu.tsx @@ -71,8 +71,11 @@ let ProfileMenu = ({ const loggedOutWarningPromptControl = Prompt.usePromptControl() const showLoggedOutWarning = React.useMemo(() => { - return !!profile.labels?.find(label => label.val === '!no-unauthenticated') - }, [profile.labels]) + return ( + profile.did !== currentAccount?.did && + !!profile.labels?.find(label => label.val === '!no-unauthenticated') + ) + }, [currentAccount, profile]) const invalidateProfileQuery = React.useCallback(() => { queryClient.invalidateQueries({ diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index b6873ff8..2486b73d 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -196,6 +196,9 @@ let PostDropdownBtn = ({ ) }, [postAuthor]) + const showLoggedOutWarning = + postAuthor.did !== currentAccount?.did && hideInPWI + const onSharePost = React.useCallback(() => { const url = toShareUrl(href) shareUrl(url) @@ -296,7 +299,7 @@ let PostDropdownBtn = ({ testID="postDropdownShareBtn" label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)} onPress={() => { - if (hideInPWI) { + if (showLoggedOutWarning) { loggedOutWarningPromptControl.open() } else { onSharePost() diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index d42590e9..c389855e 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -27,7 +27,7 @@ import { usePostLikeMutationQueue, usePostRepostMutationQueue, } from '#/state/queries/post' -import {useRequireAuth} from '#/state/session' +import {useRequireAuth, useSession} from '#/state/session' import {useComposerControls} from '#/state/shell/composer' import {atoms as a, useTheme} from '#/alf' import {useDialogControl} from '#/components/Dialog' @@ -64,6 +64,7 @@ let PostCtrls = ({ const t = useTheme() const {_} = useLingui() const {openComposer} = useComposerControls() + const {currentAccount} = useSession() const [queueLike, queueUnlike] = usePostLikeMutationQueue(post, logContext) const [queueRepost, queueUnrepost] = usePostRepostMutationQueue( post, @@ -75,10 +76,11 @@ let PostCtrls = ({ const playHaptic = useHaptics() const shouldShowLoggedOutWarning = React.useMemo(() => { - return !!post.author.labels?.find( - label => label.val === '!no-unauthenticated', + return ( + post.author.did !== currentAccount?.did && + !!post.author.labels?.find(label => label.val === '!no-unauthenticated') ) - }, [post]) + }, [currentAccount, post]) const defaultCtrlColor = React.useMemo( () => ({