From a0a5967264376dcf4900f46ae1141301767cfb95 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 5 Oct 2024 20:04:53 +0900 Subject: [PATCH] Split GifEmbed props --- src/view/com/composer/GifAltText.tsx | 4 +++- .../util/post-embeds/ExternalLinkEmbed.tsx | 12 ++++++++++- src/view/com/util/post-embeds/GifEmbed.tsx | 21 ++++++++----------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/view/com/composer/GifAltText.tsx b/src/view/com/composer/GifAltText.tsx index 90d20d94f7..9b1d12b3ce 100644 --- a/src/view/com/composer/GifAltText.tsx +++ b/src/view/com/composer/GifAltText.tsx @@ -200,7 +200,9 @@ function AltTextInner({ + const parsedAlt = parseAltFromGIFDescription(link.description) + return ( + + ) } return ( diff --git a/src/view/com/util/post-embeds/GifEmbed.tsx b/src/view/com/util/post-embeds/GifEmbed.tsx index a1af6ab26b..fc66278c95 100644 --- a/src/view/com/util/post-embeds/GifEmbed.tsx +++ b/src/view/com/util/post-embeds/GifEmbed.tsx @@ -7,12 +7,10 @@ import { View, ViewStyle, } from 'react-native' -import {AppBskyEmbedExternal} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {HITSLOP_20} from '#/lib/constants' -import {parseAltFromGIFDescription} from '#/lib/gif-alt-text' import {EmbedPlayerParams} from '#/lib/strings/embed-player' import {isWeb} from '#/platform/detection' import {useAutoplayDisabled} from '#/state/preferences' @@ -77,12 +75,16 @@ function PlaybackControls({ export function GifEmbed({ params, - link, + thumb, + altText, + isPreferredAltText, hideAlt, style = {width: '100%'}, }: { params: EmbedPlayerParams - link: AppBskyEmbedExternal.ViewExternal + thumb: string | undefined + altText: string + isPreferredAltText: boolean hideAlt?: boolean style?: StyleProp }) { @@ -111,11 +113,6 @@ export function GifEmbed({ playerRef.current?.toggleAsync() }, []) - const parsedAlt = React.useMemo( - () => parseAltFromGIFDescription(link.description), - [link], - ) - return ( {!playerState.isPlaying && ( )} - {!hideAlt && parsedAlt.isPreferred && } + {!hideAlt && isPreferredAltText && } )