1
1
import 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' ;
4
4
5
5
import { isValidUrl } from '../../../../../lib/methods/helpers/isValidUrl' ;
6
6
import { useTheme } from '../../../../../theme' ;
@@ -11,6 +11,7 @@ import { WidthAwareContext } from '../../WidthAwareView';
11
11
import { useUserPreferences } from '../../../../../lib/methods' ;
12
12
import { AUTOPLAY_GIFS_PREFERENCES_KEY } from '../../../../../lib/constants' ;
13
13
import ImageBadge from './ImageBadge' ;
14
+ import log from '../../../../../lib/methods/helpers/log' ;
14
15
15
16
export const MessageImage = React . memo ( ( { uri, status, encrypted = false , imagePreview, imageType } : IMessageImage ) => {
16
17
const { colors } = useTheme ( ) ;
@@ -22,8 +23,12 @@ export const MessageImage = React.memo(({ uri, status, encrypted = false, imageP
22
23
23
24
useEffect ( ( ) => {
24
25
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 } ) ;
27
32
} ) ;
28
33
}
29
34
} , [ uri , status ] ) ;
@@ -62,13 +67,13 @@ export const MessageImage = React.memo(({ uri, status, encrypted = false, imageP
62
67
< >
63
68
{ showImage ? (
64
69
< 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' />
66
71
</ View >
67
72
) : null }
68
73
{ [ 'loading' , 'to-download' ] . includes ( status ) || ( status === 'downloaded' && ! showImage ) ? (
69
74
< >
70
75
{ imagePreview && imageType && ! encrypted ? (
71
- < ExpoImage
76
+ < Image
72
77
autoplay = { autoplayGifs }
73
78
style = { styles . image }
74
79
source = { { uri : `data:${ imageType } ;base64,${ imagePreview } ` } }
0 commit comments