1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Fix warnings and errors

This commit is contained in:
xmflsct
2023-01-09 22:28:53 +01:00
parent b9c4b139f5
commit a4e97ccb1c
6 changed files with 25 additions and 22 deletions

View File

@ -55,14 +55,9 @@ const GracefullyImage = ({
const { colors } = useTheme()
const [imageLoaded, setImageLoaded] = useState(false)
const [currentUri, setCurrentUri] = useState<string | undefined>(uri.original || uri.remote)
const source = {
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
}
const onLoad = () => {
setImageLoaded(true)
if (setImageDimensions && source.uri) {
Image.getSize(source.uri, (width, height) => setImageDimensions({ width, height }))
}
uri: reduceMotionEnabled && uri.static ? uri.static : currentUri
}
const blurhashView = () => {
@ -92,11 +87,19 @@ const GracefullyImage = ({
/>
) : null}
<FastImage
source={{
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
}}
source={source}
style={[{ flex: 1 }, imageStyle]}
onLoad={onLoad}
onLoad={() => {
setImageLoaded(true)
if (setImageDimensions && source.uri) {
Image.getSize(source.uri, (width, height) => setImageDimensions({ width, height }))
}
}}
onError={() => {
if (uri.original && uri.original === currentUri && uri.remote) {
setCurrentUri(uri.remote)
}
}}
/>
{blurhashView()}
</Pressable>