diff --git a/src/components/ImageWithLoading.tsx b/src/components/ImageWithLoading.tsx index 6a236ab06970..f3a1a208560e 100644 --- a/src/components/ImageWithLoading.tsx +++ b/src/components/ImageWithLoading.tsx @@ -51,10 +51,6 @@ function ImageWithLoading({ const isLoadedRef = useRef(null); const [isImageCached, setIsImageCached] = useState(true); const [isLoading, setIsLoading] = useState(false); - // The full-resolution image is not guaranteed to ever emit `onLoad`/`onError` (e.g. a receipt derivative that is - // still being generated server-side), so `isLoading` can stay `true` indefinitely. Once the low-resolution preview - // is on screen we have something readable to show, so the loading state must stop being visible at that point. - const [isThumbnailLoading, setIsThumbnailLoading] = useState(!!previewUri); const {isOffline} = useNetwork(); const handleError = () => { @@ -101,12 +97,9 @@ function ImageWithLoading({ { - setIsThumbnailLoading(false); - onLoad?.(e); - }} + onLoad={onLoad} loadingIconSize={loadingIconSize} loadingIndicatorStyles={loadingIndicatorStyles} /> @@ -132,13 +125,12 @@ function ImageWithLoading({ isLoadedRef.current = false; setIsImageCached(false); setIsLoading(true); - setIsThumbnailLoading(!!previewUri); waitForSession?.(); }} loadingIconSize={loadingIconSize} loadingIndicatorStyles={loadingIndicatorStyles} /> - {isLoading && (!previewUri || isThumbnailLoading) && !isImageCached && !isOffline && ( + {(previewUri ? isLoading : isLoading && !isImageCached) && !isOffline && (