Skip to content

Commit

Permalink
Hide translate/copy text options when !no-unauthenticated (#3573)
Browse files Browse the repository at this point in the history
* hide translate/copy text options when no-pwi

* only do this for no-unauth

* always show if logged in

* swap order of OR
  • Loading branch information
mozzius authored Apr 16, 2024
1 parent f771a59 commit 6980cc7
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/view/com/util/forms/PostDropdownBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ let PostDropdownBtn = ({
hidePost({uri: postUri})
}, [postUri, hidePost])

const shouldShowLoggedOutWarning = React.useMemo(() => {
const hideInPWI = React.useMemo(() => {
return !!postAuthor.labels?.find(
label => label.val === '!no-unauthenticated',
)
Expand All @@ -183,7 +183,7 @@ let PostDropdownBtn = ({
shareUrl(url)
}, [href])

const canEmbed = isWeb && gtMobile && !shouldShowLoggedOutWarning
const canEmbed = isWeb && gtMobile && !hideInPWI

return (
<EventStopper onKeyDown={false}>
Expand Down Expand Up @@ -215,27 +215,31 @@ let PostDropdownBtn = ({

<Menu.Outer>
<Menu.Group>
<Menu.Item
testID="postDropdownTranslateBtn"
label={_(msg`Translate`)}
onPress={onOpenTranslate}>
<Menu.ItemText>{_(msg`Translate`)}</Menu.ItemText>
<Menu.ItemIcon icon={Translate} position="right" />
</Menu.Item>
{(!hideInPWI || hasSession) && (
<>
<Menu.Item
testID="postDropdownTranslateBtn"
label={_(msg`Translate`)}
onPress={onOpenTranslate}>
<Menu.ItemText>{_(msg`Translate`)}</Menu.ItemText>
<Menu.ItemIcon icon={Translate} position="right" />
</Menu.Item>

<Menu.Item
testID="postDropdownCopyTextBtn"
label={_(msg`Copy post text`)}
onPress={onCopyPostText}>
<Menu.ItemText>{_(msg`Copy post text`)}</Menu.ItemText>
<Menu.ItemIcon icon={ClipboardIcon} position="right" />
</Menu.Item>
<Menu.Item
testID="postDropdownCopyTextBtn"
label={_(msg`Copy post text`)}
onPress={onCopyPostText}>
<Menu.ItemText>{_(msg`Copy post text`)}</Menu.ItemText>
<Menu.ItemIcon icon={ClipboardIcon} position="right" />
</Menu.Item>
</>
)}

<Menu.Item
testID="postDropdownShareBtn"
label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)}
onPress={() => {
if (shouldShowLoggedOutWarning) {
if (hideInPWI) {
loggedOutWarningPromptControl.open()
} else {
onSharePost()
Expand Down

0 comments on commit 6980cc7

Please sign in to comment.