From 641c10b5e9d021f9f006e01b7c1abd49beb9aa38 Mon Sep 17 00:00:00 2001 From: Daniela Henkel Date: Sat, 6 Sep 2025 22:23:01 +0200 Subject: [PATCH] copy via bsky.app button in a couple places --- .../ShareMenu/ShareMenuItems.web.tsx | 38 ++++++++++++++----- src/lib/strings/url-helpers.ts | 10 +++++ src/view/com/profile/ProfileMenu.tsx | 25 +++++++++++- src/view/screens/ProfileList.tsx | 30 ++++++++++++--- 4 files changed, 86 insertions(+), 17 deletions(-) diff --git a/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx b/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx index b04d5ada3..b6be3f006 100644 --- a/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx +++ b/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx @@ -8,7 +8,7 @@ import type React from 'react' import {makeProfileLink} from '#/lib/routes/links' import {type NavigationProp} from '#/lib/routes/types' import {shareText, shareUrl} from '#/lib/sharing' -import {toShareUrl} from '#/lib/strings/url-helpers' +import {toShareUrl, toShareUrlBsky} from '#/lib/strings/url-helpers' import {logger} from '#/logger' import {isWeb} from '#/platform/detection' import {useAgeAssurance} from '#/state/ageAssurance/useAgeAssurance' @@ -63,6 +63,13 @@ let ShareMenuItems = ({ onShareProp() } + const onCopyLinkBsky = () => { + logger.metric('share:press:copyLink', {}, {statsig: true}) + const url = toShareUrlBsky(href) + shareUrl(url) + onShareProp() + } + const onSelectChatToShareTo = (conversation: string) => { logger.metric('share:press:dmSelected', {}, {statsig: true}) navigation.navigate('MessagesConversation', { @@ -82,15 +89,26 @@ let ShareMenuItems = ({ } const copyLinkItem = ( - - - Copy link to post - - - + + + + Copy link to post + + + + + + Copy via bsky.app + + + + ) return ( diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts index 38e7a33f9..be1820906 100644 --- a/src/lib/strings/url-helpers.ts +++ b/src/lib/strings/url-helpers.ts @@ -88,6 +88,16 @@ export function toShareUrl(url: string): string { return url } +// separate one for bluesky, im fully aware i could just have it in one function but im more worried about code conflicts from this +export function toShareUrlBsky(url: string): string { + if (!url.startsWith('https')) { + const urlp = new URL('https://bsky.app') + urlp.pathname = url + url = urlp.toString() + } + return url +} + export function toBskyAppUrl(url: string): string { return new URL(url, BSKY_APP_HOST).toString() } diff --git a/src/view/com/profile/ProfileMenu.tsx b/src/view/com/profile/ProfileMenu.tsx index 63bf29fdc..871e7d565 100644 --- a/src/view/com/profile/ProfileMenu.tsx +++ b/src/view/com/profile/ProfileMenu.tsx @@ -10,7 +10,7 @@ import {HITSLOP_20} from '#/lib/constants' import {makeProfileLink} from '#/lib/routes/links' import {type NavigationProp} from '#/lib/routes/types' import {shareText, shareUrl} from '#/lib/sharing' -import {toShareUrl} from '#/lib/strings/url-helpers' +import {toShareUrl, toShareUrlBsky} from '#/lib/strings/url-helpers' import {logger} from '#/logger' import {isWeb} from '#/platform/detection' import {type Shadow} from '#/state/cache/types' @@ -118,6 +118,10 @@ let ProfileMenu = ({ shareUrl(toShareUrl(makeProfileLink(profile))) }, [profile]) + const onPressShareBsky = React.useCallback(() => { + shareUrl(toShareUrlBsky(makeProfileLink(profile))) + }, [profile]) + const onPressAddRemoveLists = React.useCallback(() => { openModal({ name: 'user-add-remove-lists', @@ -270,6 +274,25 @@ let ProfileMenu = ({ + { + if (showLoggedOutWarning) { + loggedOutWarningPromptControl.open() + } else { + onPressShareBsky() + } + }}> + + {isWeb ? ( + Copy via bsky.app + ) : ( + Share via... + )} + + + { + const url = toShareUrlBsky(`/profile/${list.creator.did}/lists/${rkey}`) + shareUrl(url) + }, [list, rkey]) + const dropdownItems: DropdownItem[] = useMemo(() => { let items: DropdownItem[] = [ { @@ -520,6 +525,18 @@ function Header({ web: 'share', }, }, + { + testID: 'listHeaderDropdownShareBtn', + label: isWeb ? _(msg`Copy via bsky.app`) : _(msg`Share`), + onPress: onPressShareBsky, + icon: { + ios: { + name: 'square.and.arrow.up', + }, + android: '', + web: 'share', + }, + }, ] if (savedFeedConfig) { @@ -633,21 +650,22 @@ function Header({ }, [ _, onPressShare, + onPressShareBsky, + savedFeedConfig, isOwner, isModList, isPinned, isCurateList, + isBlocking, + isMuting, + onRemoveFromSavedFeeds, onPressEdit, deleteListPromptControl.open, onPressReport, isPending, - isBlocking, - isMuting, + removeSavedFeed, onUnsubscribeMute, onUnsubscribeBlock, - removeSavedFeed, - savedFeedConfig, - onRemoveFromSavedFeeds, ]) const subscribeDropdownItems: DropdownItem[] = useMemo(() => { -- 2.54.0