diff options
author | Minseo Lee <itoupluk427@gmail.com> | 2024-03-15 08:59:56 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-15 08:59:56 +0900 |
commit | d9b94f54efaf0ec0d0256ffd84e900ebbdb826ba (patch) | |
tree | 433cca9e69382b6b459f54ed8ea09f54ceae3da6 /src | |
parent | 4813f261581e83d6d6c2c2b8063c208ecdb5de34 (diff) | |
parent | 6279c5cf3186183367d376d8ba9213688f37d252 (diff) | |
download | voidsky-d9b94f54efaf0ec0d0256ffd84e900ebbdb826ba.tar.zst |
Merge branch 'bluesky-social:main' into patch-3
Diffstat (limited to 'src')
-rw-r--r-- | src/view/com/profile/ProfileMenu.tsx | 23 | ||||
-rw-r--r-- | src/view/com/util/forms/PostDropdownBtn.tsx | 30 |
2 files changed, 50 insertions, 3 deletions
diff --git a/src/view/com/profile/ProfileMenu.tsx b/src/view/com/profile/ProfileMenu.tsx index 7c6db1ed8..0baa4f394 100644 --- a/src/view/com/profile/ProfileMenu.tsx +++ b/src/view/com/profile/ProfileMenu.tsx @@ -58,6 +58,11 @@ let ProfileMenu = ({ ) const blockPromptControl = Prompt.usePromptControl() + const loggedOutWarningPromptControl = Prompt.usePromptControl() + + const showLoggedOutWarning = React.useMemo(() => { + return !!profile.labels?.find(label => label.val === '!no-unauthenticated') + }, [profile.labels]) const invalidateProfileQuery = React.useCallback(() => { queryClient.invalidateQueries({ @@ -192,7 +197,13 @@ let ProfileMenu = ({ <Menu.Item testID="profileHeaderDropdownShareBtn" label={_(msg`Share`)} - onPress={onPressShare}> + onPress={() => { + if (showLoggedOutWarning) { + loggedOutWarningPromptControl.open() + } else { + onPressShare() + } + }}> <Menu.ItemText> <Trans>Share</Trans> </Menu.ItemText> @@ -310,6 +321,16 @@ let ProfileMenu = ({ } confirmButtonColor={profile.viewer?.blocking ? undefined : 'negative'} /> + + <Prompt.Basic + control={loggedOutWarningPromptControl} + title={_(msg`Note about sharing`)} + description={_( + msg`This profile is only visible to logged-in users. It won't be visible to people who aren't logged in.`, + )} + onConfirm={onPressShare} + confirmButtonCta={_(msg`Share anyway`)} + /> </EventStopper> ) } diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index 84a047c40..8fc3d9ea6 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -85,11 +85,13 @@ let PostDropdownBtn = ({ const {mutedWordsDialogControl} = useGlobalDialogsControlContext() const deletePromptControl = useDialogControl() const hidePromptControl = useDialogControl() + const loggedOutWarningPromptControl = useDialogControl() const rootUri = record.reply?.root?.uri || postUri const isThreadMuted = mutedThreads.includes(rootUri) const isPostHidden = hiddenPosts && hiddenPosts.includes(postUri) const isAuthor = postAuthor.did === currentAccount?.did + const href = React.useMemo(() => { const urip = new AtUri(postUri) return makeProfileLink(postAuthor, 'post', urip.rkey) @@ -167,6 +169,17 @@ let PostDropdownBtn = ({ hidePost({uri: postUri}) }, [postUri, hidePost]) + const shouldShowLoggedOutWarning = React.useMemo(() => { + return !!postAuthor.labels?.find( + label => label.val === '!no-unauthenticated', + ) + }, [postAuthor]) + + const onSharePost = React.useCallback(() => { + const url = toShareUrl(href) + shareUrl(url) + }, [href]) + return ( <EventStopper onKeyDown={false}> <Menu.Root> @@ -217,8 +230,11 @@ let PostDropdownBtn = ({ testID="postDropdownShareBtn" label={isWeb ? _(msg`Copy link to post`) : _(msg`Share`)} onPress={() => { - const url = toShareUrl(href) - shareUrl(url) + if (shouldShowLoggedOutWarning) { + loggedOutWarningPromptControl.open() + } else { + onSharePost() + } }}> <Menu.ItemText> {isWeb ? _(msg`Copy link to post`) : _(msg`Share`)} @@ -342,6 +358,16 @@ let PostDropdownBtn = ({ onConfirm={onHidePost} confirmButtonCta={_(msg`Hide`)} /> + + <Prompt.Basic + control={loggedOutWarningPromptControl} + title={_(msg`Note about sharing`)} + description={_( + msg`This post is only visible to logged-in users. It won't be visible to people who aren't logged in.`, + )} + onConfirm={onSharePost} + confirmButtonCta={_(msg`Share anyway`)} + /> </EventStopper> ) } |