diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-02-05 23:58:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 15:58:03 -0800 |
commit | 2f1ce117d7db8db168303f6064e69024e920585e (patch) | |
tree | 9577b96bc3066f5b73c14d7585fef530bf94f6e8 | |
parent | 2754121f6790216a4371c98b4b1934c8c77589ec (diff) | |
download | voidsky-2f1ce117d7db8db168303f6064e69024e920585e.tar.zst |
Long press external embed to share (#2621)
* long press external embed to share * use existing shareUrl function
-rw-r--r-- | src/view/com/util/post-embeds/index.tsx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/view/com/util/post-embeds/index.tsx b/src/view/com/util/post-embeds/index.tsx index 6f168a293..7e235babb 100644 --- a/src/view/com/util/post-embeds/index.tsx +++ b/src/view/com/util/post-embeds/index.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, {useCallback} from 'react' import { StyleSheet, StyleProp, @@ -29,6 +29,8 @@ import {ListEmbed} from './ListEmbed' import {isCauseALabelOnUri, isQuoteBlurred} from 'lib/moderation' import {FeedSourceCard} from 'view/com/feeds/FeedSourceCard' import {ContentHider} from '../moderation/ContentHider' +import {isNative} from '#/platform/detection' +import {shareUrl} from '#/lib/sharing' type Embed = | AppBskyEmbedRecord.View @@ -51,6 +53,16 @@ export function PostEmbeds({ const pal = usePalette('default') const {openLightbox} = useLightboxControls() + const externalUri = AppBskyEmbedExternal.isView(embed) + ? embed.external.uri + : null + + const onShareExternal = useCallback(() => { + if (externalUri && isNative) { + shareUrl(externalUri) + } + }, [externalUri]) + // quote post with media // = if (AppBskyEmbedRecordWithMedia.isView(embed)) { @@ -164,7 +176,8 @@ export function PostEmbeds({ anchorNoUnderline href={link.uri} style={[styles.extOuter, pal.view, pal.borderDark, style]} - hoverStyle={{borderColor: pal.colors.borderLinkHover}}> + hoverStyle={{borderColor: pal.colors.borderLinkHover}} + onLongPress={onShareExternal}> <ExternalLinkEmbed link={link} /> </Link> ) |