diff options
author | dan <dan.abramov@gmail.com> | 2024-11-18 21:55:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-18 21:55:20 +0000 |
commit | ee49ca7a3dbaf40d429aae17225447aa4061dc2d (patch) | |
tree | 85252e1e40de623389b973a162f63f307256a653 /src | |
parent | b87c94e6d95169df2f14ce489a248506a755139f (diff) | |
download | voidsky-ee49ca7a3dbaf40d429aae17225447aa4061dc2d.tar.zst |
Hardcode Giphy embed height (#6475)
Diffstat (limited to 'src')
-rw-r--r-- | src/view/com/util/post-embeds/ExternalGifEmbed.tsx | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/view/com/util/post-embeds/ExternalGifEmbed.tsx b/src/view/com/util/post-embeds/ExternalGifEmbed.tsx index 6db4d6fef..39c1d109e 100644 --- a/src/view/com/util/post-embeds/ExternalGifEmbed.tsx +++ b/src/view/com/util/post-embeds/ExternalGifEmbed.tsx @@ -1,16 +1,11 @@ import React from 'react' -import { - ActivityIndicator, - GestureResponderEvent, - LayoutChangeEvent, - Pressable, -} from 'react-native' -import {Image, ImageLoadEventData} from 'expo-image' +import {ActivityIndicator, GestureResponderEvent, Pressable} from 'react-native' +import {Image} from 'expo-image' import {AppBskyEmbedExternal} from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {EmbedPlayerParams, getGifDims} from '#/lib/strings/embed-player' +import {EmbedPlayerParams} from '#/lib/strings/embed-player' import {isIOS, isNative, isWeb} from '#/platform/detection' import {useExternalEmbedsPrefs} from '#/state/preferences' import {atoms as a, useTheme} from '#/alf' @@ -28,20 +23,15 @@ export function ExternalGifEmbed({ }) { const t = useTheme() const externalEmbedsPrefs = useExternalEmbedsPrefs() - const {_} = useLingui() const consentDialogControl = useDialogControl() - const thumbHasLoaded = React.useRef(false) - const viewWidth = React.useRef(0) - // Tracking if the placer has been activated const [isPlayerActive, setIsPlayerActive] = React.useState(false) // Tracking whether the gif has been loaded yet const [isPrefetched, setIsPrefetched] = React.useState(false) // Tracking whether the image is animating const [isAnimating, setIsAnimating] = React.useState(true) - const [imageDims, setImageDims] = React.useState({height: 100, width: 1}) // Used for controlling animation const imageRef = React.useRef<Image>(null) @@ -93,16 +83,6 @@ export function ExternalGifEmbed({ ], ) - const onLoad = React.useCallback((e: ImageLoadEventData) => { - if (thumbHasLoaded.current) return - setImageDims(getGifDims(e.source.height, e.source.width, viewWidth.current)) - thumbHasLoaded.current = true - }, []) - - const onLayout = React.useCallback((e: LayoutChangeEvent) => { - viewWidth.current = e.nativeEvent.layout.width - }, []) - return ( <> <EmbedConsentDialog @@ -113,7 +93,7 @@ export function ExternalGifEmbed({ <Pressable style={[ - {height: imageDims.height}, + {height: 300}, a.w_full, a.overflow_hidden, { @@ -122,7 +102,6 @@ export function ExternalGifEmbed({ }, ]} onPress={onPlayPress} - onLayout={onLayout} accessibilityRole="button" accessibilityHint={_(msg`Plays the GIF`)} accessibilityLabel={_(msg`Play ${link.title}`)}> @@ -135,7 +114,6 @@ export function ExternalGifEmbed({ }} // Web uses the thumb to control playback style={{flex: 1}} ref={imageRef} - onLoad={onLoad} autoplay={isAnimating} contentFit="contain" accessibilityIgnoresInvertColors |