@@ -270,23 +270,12 @@ function ThreadMarkdownImageView(props: {
270270 overflow : "hidden" ,
271271 } }
272272 >
273- < Image
273+ < ThreadMarkdownImageRequest
274274 key = { props . uri }
275- source = { { uri : props . uri } }
276- resizeMode = "contain"
277- accessible = { false }
278- onLoad = { ( event ) => {
279- const { width, height } = event . nativeEvent . source ;
280- setSourceSize ( { width, height } ) ;
281- } }
275+ uri = { props . uri }
276+ onLoad = { setSourceSize }
282277 onError = { ( ) => setFailedUri ( props . uri ) }
283- style = { {
284- width : "100%" ,
285- height : "100%" ,
286- opacity : displaySize === null ? 0 : 1 ,
287- } }
288278 />
289- { displaySize === null ? < ActivityIndicator style = { StyleSheet . absoluteFill } /> : null }
290279 </ View >
291280 </ TouchableOpacity >
292281 ) }
@@ -299,6 +288,31 @@ function ThreadMarkdownImageView(props: {
299288 ) ;
300289}
301290
291+ function ThreadMarkdownImageRequest ( props : {
292+ readonly uri : string ;
293+ readonly onLoad : ( sourceSize : { width : number ; height : number } ) => void ;
294+ readonly onError : ( ) => void ;
295+ } ) {
296+ const [ loaded , setLoaded ] = useState ( false ) ;
297+
298+ return (
299+ < >
300+ < Image
301+ source = { { uri : props . uri } }
302+ resizeMode = "contain"
303+ accessible = { false }
304+ onLoad = { ( event ) => {
305+ setLoaded ( true ) ;
306+ props . onLoad ( event . nativeEvent . source ) ;
307+ } }
308+ onError = { props . onError }
309+ style = { { width : "100%" , height : "100%" , opacity : loaded ? 1 : 0 } }
310+ />
311+ { loaded ? null : < ActivityIndicator style = { StyleSheet . absoluteFill } /> }
312+ </ >
313+ ) ;
314+ }
315+
302316/** Markdown image whose src is a workspace file — loads through a signed asset URL. */
303317function ThreadMarkdownImage ( props : {
304318 readonly environmentId : EnvironmentId ;
0 commit comments