11import React , { useContext , useEffect , useState } from 'react' ;
2- import { View , ViewStyle , Image } from 'react-native' ;
3- import { Image as ExpoImage } from 'expo-image' ;
2+ import { View , ViewStyle } from 'react-native' ;
3+ import { Image } from 'expo-image' ;
44
55import { isValidUrl } from '../../../../../lib/methods/helpers/isValidUrl' ;
66import { useTheme } from '../../../../../theme' ;
@@ -11,6 +11,7 @@ import { WidthAwareContext } from '../../WidthAwareView';
1111import { useUserPreferences } from '../../../../../lib/methods' ;
1212import { AUTOPLAY_GIFS_PREFERENCES_KEY } from '../../../../../lib/constants' ;
1313import ImageBadge from './ImageBadge' ;
14+ import log from '../../../../../lib/methods/helpers/log' ;
1415
1516export const MessageImage = React . memo ( ( { uri, status, encrypted = false , imagePreview, imageType } : IMessageImage ) => {
1617 const { colors } = useTheme ( ) ;
@@ -22,8 +23,12 @@ export const MessageImage = React.memo(({ uri, status, encrypted = false, imageP
2223
2324 useEffect ( ( ) => {
2425 if ( status === 'downloaded' ) {
25- Image . getSize ( uri , ( width , height ) => {
26- setImageDimensions ( { width, height } ) ;
26+ Image . loadAsync ( uri , {
27+ onError : e => {
28+ log ( e ) ;
29+ }
30+ } ) . then ( image => {
31+ setImageDimensions ( { width : image . width , height : image . height } ) ;
2732 } ) ;
2833 }
2934 } , [ uri , status ] ) ;
@@ -62,13 +67,13 @@ export const MessageImage = React.memo(({ uri, status, encrypted = false, imageP
6267 < >
6368 { showImage ? (
6469 < View style = { [ containerStyle , borderStyle ] } >
65- < ExpoImage autoplay = { autoplayGifs } style = { imageStyle } source = { { uri : encodeURI ( uri ) } } contentFit = 'cover' />
70+ < Image autoplay = { autoplayGifs } style = { imageStyle } source = { { uri : encodeURI ( uri ) } } contentFit = 'cover' />
6671 </ View >
6772 ) : null }
6873 { [ 'loading' , 'to-download' ] . includes ( status ) || ( status === 'downloaded' && ! showImage ) ? (
6974 < >
7075 { imagePreview && imageType && ! encrypted ? (
71- < ExpoImage
76+ < Image
7277 autoplay = { autoplayGifs }
7378 style = { styles . image }
7479 source = { { uri : `data:${ imageType } ;base64,${ imagePreview } ` } }
0 commit comments