From eed19808cc731b89b1d0b4c06f36112a7f3dd1e1 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 29 Nov 2022 18:45:04 +0530 Subject: [PATCH] move isSourceLoaded check to checkExifAvailable --- src/components/PhotoViewer/index.tsx | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/PhotoViewer/index.tsx b/src/components/PhotoViewer/index.tsx index 47ee6d853..18ff57255 100644 --- a/src/components/PhotoViewer/index.tsx +++ b/src/components/PhotoViewer/index.tsx @@ -311,8 +311,7 @@ function PhotoViewer(props: Iprops) { if ( !currItem || !exifCopy?.current?.value === null || - exifCopy?.current?.key === currItem.src || - !currItem.isSourceLoaded + exifCopy?.current?.key === currItem.src ) { return; } @@ -325,8 +324,7 @@ function PhotoViewer(props: Iprops) { if ( !currItem || !exifCopy?.current?.value === null || - exifCopy?.current?.key === currItem.src || - !currItem.isSourceLoaded + exifCopy?.current?.key === currItem.src ) { return; } @@ -424,22 +422,24 @@ function PhotoViewer(props: Iprops) { return; } try { - console.log('starting processing'); - exifExtractionInProgress.current = file.src; - const imageBlob = await (await fetch(file.src)).blob(); - const exifData = (await exifr.parse(imageBlob)) as Record< - string, - any - >; - console.log({ exifData }); - console.log(exifExtractionInProgress, file.src); - if (exifExtractionInProgress.current === file.src) { - if (exifData) { - console.log('set extracted metadata'); - setExif({ key: file.src, value: exifData }); - } else { - console.log("doesn't have metadata"); - setExif({ key: file.src, value: null }); + if (file.isSourceLoaded) { + console.log('starting processing'); + exifExtractionInProgress.current = file.src; + const imageBlob = await (await fetch(file.src)).blob(); + const exifData = (await exifr.parse(imageBlob)) as Record< + string, + any + >; + console.log({ exifData }); + console.log(exifExtractionInProgress, file.src); + if (exifExtractionInProgress.current === file.src) { + if (exifData) { + console.log('set extracted metadata'); + setExif({ key: file.src, value: exifData }); + } else { + console.log("doesn't have metadata"); + setExif({ key: file.src, value: null }); + } } } } finally {