diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-11-23 16:20:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-23 16:20:24 -0800 |
commit | 32bf8122e8c8a0fbadd53b8a015cfbc9014519a2 (patch) | |
tree | 55bd24596e6fadadbf4326b26e3d14e418c5c7bb /src/view/com/util/post-embeds/ExternalGifEmbed.tsx | |
parent | 523d1f01a51c0e85e49916fb42b204f7004ffac1 (diff) | |
parent | b4d07c4112b9a62b5380948051aa4a7fd391a2d4 (diff) | |
download | voidsky-32bf8122e8c8a0fbadd53b8a015cfbc9014519a2.tar.zst |
Merge branch 'main' into main
Diffstat (limited to 'src/view/com/util/post-embeds/ExternalGifEmbed.tsx')
-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 |