[Drafts] Revert unnecessary gif changes (#9788)
* revert unnecessary gif changes * Update ExternalEmbed.tsx
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {useRef, useState} from 'react'
|
||||||
import {
|
import {
|
||||||
Pressable,
|
Pressable,
|
||||||
type StyleProp,
|
type StyleProp,
|
||||||
@@ -91,9 +91,9 @@ export function GifEmbed({
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const autoplayDisabled = useAutoplayDisabled()
|
const autoplayDisabled = useAutoplayDisabled()
|
||||||
|
|
||||||
const playerRef = React.useRef<GifView>(null)
|
const playerRef = useRef<GifView>(null)
|
||||||
|
|
||||||
const [playerState, setPlayerState] = React.useState<{
|
const [playerState, setPlayerState] = useState<{
|
||||||
isPlaying: boolean
|
isPlaying: boolean
|
||||||
isLoaded: boolean
|
isLoaded: boolean
|
||||||
}>({
|
}>({
|
||||||
@@ -101,23 +101,18 @@ export function GifEmbed({
|
|||||||
isLoaded: false,
|
isLoaded: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const onPlayerStateChange = React.useCallback(
|
const onPlayerStateChange = (e: GifViewStateChangeEvent) => {
|
||||||
(e: GifViewStateChangeEvent) => {
|
setPlayerState(e.nativeEvent)
|
||||||
setPlayerState(e.nativeEvent)
|
}
|
||||||
},
|
|
||||||
[],
|
|
||||||
)
|
|
||||||
|
|
||||||
const onPress = React.useCallback(() => {
|
const onPress = () => {
|
||||||
playerRef.current?.toggleAsync()
|
void playerRef.current?.toggleAsync()
|
||||||
}, [])
|
}
|
||||||
|
|
||||||
let aspectRatio = 1
|
let aspectRatio = 1
|
||||||
if (params.dimensions) {
|
if (params.dimensions) {
|
||||||
const ratio = params.dimensions.width / params.dimensions.height
|
const ratio = params.dimensions.width / params.dimensions.height
|
||||||
if (!isNaN(ratio) && isFinite(ratio)) {
|
aspectRatio = clamp(ratio, 0.75, 4)
|
||||||
aspectRatio = clamp(ratio, 0.75, 4)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {useMemo} from 'react'
|
||||||
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
||||||
|
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
@@ -25,7 +25,7 @@ export const ExternalEmbedGif = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {data, error} = useResolveGifQuery(gif)
|
const {data, error} = useResolveGifQuery(gif)
|
||||||
const linkInfo = React.useMemo(
|
const linkInfo = useMemo(
|
||||||
() =>
|
() =>
|
||||||
data && {
|
data && {
|
||||||
title: data.title ?? data.uri,
|
title: data.title ?? data.uri,
|
||||||
@@ -83,7 +83,7 @@ export const ExternalEmbedLink = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {data, error} = useResolveLinkQuery(uri)
|
const {data, error} = useResolveLinkQuery(uri)
|
||||||
const linkComponent = React.useMemo(() => {
|
const linkComponent = useMemo(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.type === 'external') {
|
if (data.type === 'external') {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user