Long press external embed to share (#2621)

* long press external embed to share

* use existing shareUrl function
zio/stable
Samuel Newman 2024-02-05 23:58:03 +00:00 committed by GitHub
parent 2754121f67
commit 2f1ce117d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import React from 'react' import React, {useCallback} from 'react'
import { import {
StyleSheet, StyleSheet,
StyleProp, StyleProp,
@ -29,6 +29,8 @@ import {ListEmbed} from './ListEmbed'
import {isCauseALabelOnUri, isQuoteBlurred} from 'lib/moderation' import {isCauseALabelOnUri, isQuoteBlurred} from 'lib/moderation'
import {FeedSourceCard} from 'view/com/feeds/FeedSourceCard' import {FeedSourceCard} from 'view/com/feeds/FeedSourceCard'
import {ContentHider} from '../moderation/ContentHider' import {ContentHider} from '../moderation/ContentHider'
import {isNative} from '#/platform/detection'
import {shareUrl} from '#/lib/sharing'
type Embed = type Embed =
| AppBskyEmbedRecord.View | AppBskyEmbedRecord.View
@ -51,6 +53,16 @@ export function PostEmbeds({
const pal = usePalette('default') const pal = usePalette('default')
const {openLightbox} = useLightboxControls() 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 // quote post with media
// = // =
if (AppBskyEmbedRecordWithMedia.isView(embed)) { if (AppBskyEmbedRecordWithMedia.isView(embed)) {
@ -164,7 +176,8 @@ export function PostEmbeds({
anchorNoUnderline anchorNoUnderline
href={link.uri} href={link.uri}
style={[styles.extOuter, pal.view, pal.borderDark, style]} style={[styles.extOuter, pal.view, pal.borderDark, style]}
hoverStyle={{borderColor: pal.colors.borderLinkHover}}> hoverStyle={{borderColor: pal.colors.borderLinkHover}}
onLongPress={onShareExternal}>
<ExternalLinkEmbed link={link} /> <ExternalLinkEmbed link={link} />
</Link> </Link>
) )