Don't show warning when sharing your own post in PWI opt-out mode (#4495)
parent
4e4a7bf18f
commit
99078bbff2
|
@ -71,8 +71,11 @@ let ProfileMenu = ({
|
||||||
const loggedOutWarningPromptControl = Prompt.usePromptControl()
|
const loggedOutWarningPromptControl = Prompt.usePromptControl()
|
||||||
|
|
||||||
const showLoggedOutWarning = React.useMemo(() => {
|
const showLoggedOutWarning = React.useMemo(() => {
|
||||||
return !!profile.labels?.find(label => label.val === '!no-unauthenticated')
|
return (
|
||||||
}, [profile.labels])
|
profile.did !== currentAccount?.did &&
|
||||||
|
!!profile.labels?.find(label => label.val === '!no-unauthenticated')
|
||||||
|
)
|
||||||
|
}, [currentAccount, profile])
|
||||||
|
|
||||||
const invalidateProfileQuery = React.useCallback(() => {
|
const invalidateProfileQuery = React.useCallback(() => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
|
|
|
@ -196,6 +196,9 @@ let PostDropdownBtn = ({
|
||||||
)
|
)
|
||||||
}, [postAuthor])
|
}, [postAuthor])
|
||||||
|
|
||||||
|
const showLoggedOutWarning =
|
||||||
|
postAuthor.did !== currentAccount?.did && hideInPWI
|
||||||
|
|
||||||
const onSharePost = React.useCallback(() => {
|
const onSharePost = React.useCallback(() => {
|
||||||
const url = toShareUrl(href)
|
const url = toShareUrl(href)
|
||||||
shareUrl(url)
|
shareUrl(url)
|
||||||
|
@ -296,7 +299,7 @@ let PostDropdownBtn = ({
|
||||||
testID="postDropdownShareBtn"
|
testID="postDropdownShareBtn"
|
||||||
label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)}
|
label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (hideInPWI) {
|
if (showLoggedOutWarning) {
|
||||||
loggedOutWarningPromptControl.open()
|
loggedOutWarningPromptControl.open()
|
||||||
} else {
|
} else {
|
||||||
onSharePost()
|
onSharePost()
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {
|
||||||
usePostLikeMutationQueue,
|
usePostLikeMutationQueue,
|
||||||
usePostRepostMutationQueue,
|
usePostRepostMutationQueue,
|
||||||
} from '#/state/queries/post'
|
} from '#/state/queries/post'
|
||||||
import {useRequireAuth} from '#/state/session'
|
import {useRequireAuth, useSession} from '#/state/session'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
|
@ -64,6 +64,7 @@ let PostCtrls = ({
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {openComposer} = useComposerControls()
|
const {openComposer} = useComposerControls()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
const [queueLike, queueUnlike] = usePostLikeMutationQueue(post, logContext)
|
const [queueLike, queueUnlike] = usePostLikeMutationQueue(post, logContext)
|
||||||
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
||||||
post,
|
post,
|
||||||
|
@ -75,10 +76,11 @@ let PostCtrls = ({
|
||||||
const playHaptic = useHaptics()
|
const playHaptic = useHaptics()
|
||||||
|
|
||||||
const shouldShowLoggedOutWarning = React.useMemo(() => {
|
const shouldShowLoggedOutWarning = React.useMemo(() => {
|
||||||
return !!post.author.labels?.find(
|
return (
|
||||||
label => label.val === '!no-unauthenticated',
|
post.author.did !== currentAccount?.did &&
|
||||||
|
!!post.author.labels?.find(label => label.val === '!no-unauthenticated')
|
||||||
)
|
)
|
||||||
}, [post])
|
}, [currentAccount, post])
|
||||||
|
|
||||||
const defaultCtrlColor = React.useMemo(
|
const defaultCtrlColor = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
|
Loading…
Reference in New Issue