From b715f96171e6e7c11eb64a69e26149d58e8e7692 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 16 Dec 2022 15:30:20 +0530 Subject: [PATCH 1/6] fix video filename icon --- src/components/PhotoViewer/FileInfo/RenderFileName.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PhotoViewer/FileInfo/RenderFileName.tsx b/src/components/PhotoViewer/FileInfo/RenderFileName.tsx index e2e31e062..43bbf4f5a 100644 --- a/src/components/PhotoViewer/FileInfo/RenderFileName.tsx +++ b/src/components/PhotoViewer/FileInfo/RenderFileName.tsx @@ -9,7 +9,7 @@ import { import { FlexWrapper } from 'components/Container'; import { logError } from 'utils/sentry'; import { FILE_TYPE } from 'constants/file'; -import { PhotoOutlined, VideoFileOutlined } from '@mui/icons-material'; +import { PhotoOutlined, VideocamOutlined } from '@mui/icons-material'; import InfoItem from './InfoItem'; import { makeHumanReadableStorage } from 'utils/billing'; import Box from '@mui/material/Box'; @@ -101,7 +101,7 @@ export function RenderFileName({ file.metadata.fileType === FILE_TYPE.IMAGE ? ( ) : ( - + ) } title={getFileTitle(filename, extension)} From e491234f489f489464965fd7bebc35f83d9c9bed Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 16 Dec 2022 16:08:33 +0530 Subject: [PATCH 2/6] use image icon for live-photo --- src/components/PhotoViewer/FileInfo/RenderFileName.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/PhotoViewer/FileInfo/RenderFileName.tsx b/src/components/PhotoViewer/FileInfo/RenderFileName.tsx index 43bbf4f5a..f26107228 100644 --- a/src/components/PhotoViewer/FileInfo/RenderFileName.tsx +++ b/src/components/PhotoViewer/FileInfo/RenderFileName.tsx @@ -98,10 +98,10 @@ export function RenderFileName({ <> - ) : ( + file.metadata.fileType === FILE_TYPE.VIDEO ? ( + ) : ( + ) } title={getFileTitle(filename, extension)} From 5cbba12850630a8725ae5b4e1c744ab44cd71e92 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 16 Dec 2022 16:57:02 +0530 Subject: [PATCH 3/6] dont check for exif in non image files --- src/components/PhotoViewer/FileInfo/index.tsx | 5 +++++ src/components/PhotoViewer/index.tsx | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/PhotoViewer/FileInfo/index.tsx b/src/components/PhotoViewer/FileInfo/index.tsx index b237844ec..5557225d4 100644 --- a/src/components/PhotoViewer/FileInfo/index.tsx +++ b/src/components/PhotoViewer/FileInfo/index.tsx @@ -88,6 +88,9 @@ export function FileInfo({ const closeExif = () => setShowExif(false); useEffect(() => { + console.log('file.metadata', file?.metadata); + console.log('location', location); + if (!location && file && file.metadata) { if (file.metadata.longitude || file.metadata.longitude === 0) { setLocation({ @@ -99,6 +102,8 @@ export function FileInfo({ }, [file]); useEffect(() => { + console.log('exif', exif); + console.log('location', location); if (!location && exif) { const exifLocation = getEXIFLocation(exif); if (exifLocation.latitude || exifLocation.latitude === 0) { diff --git a/src/components/PhotoViewer/index.tsx b/src/components/PhotoViewer/index.tsx index 285186fe6..c372a335b 100644 --- a/src/components/PhotoViewer/index.tsx +++ b/src/components/PhotoViewer/index.tsx @@ -307,6 +307,11 @@ function PhotoViewer(props: Iprops) { }); photoSwipe.listen('beforeChange', () => { const currItem = photoSwipe?.currItem as EnteFile; + updateFavButton(currItem); + if (currItem.metadata.fileType !== FILE_TYPE.IMAGE) { + setExif({ key: currItem.src, value: null }); + return; + } if ( !currItem || !exifCopy?.current?.value === null || @@ -316,10 +321,13 @@ function PhotoViewer(props: Iprops) { } setExif({ key: currItem.src, value: undefined }); checkExifAvailable(currItem); - updateFavButton(currItem); }); photoSwipe.listen('resize', () => { const currItem = photoSwipe?.currItem as EnteFile; + if (currItem.metadata.fileType !== FILE_TYPE.IMAGE) { + setExif({ key: currItem.src, value: null }); + return; + } if ( !currItem || !exifCopy?.current?.value === null || From 3dd9c5ea5aaef6212de8310608d1700a5939945c Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 16 Dec 2022 16:58:38 +0530 Subject: [PATCH 4/6] set exif as null if exif parsing fails --- src/components/PhotoViewer/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/PhotoViewer/index.tsx b/src/components/PhotoViewer/index.tsx index c372a335b..8c13c627e 100644 --- a/src/components/PhotoViewer/index.tsx +++ b/src/components/PhotoViewer/index.tsx @@ -448,6 +448,7 @@ function PhotoViewer(props: Iprops) { exifExtractionInProgress.current = null; } } catch (e) { + setExif({ key: file.src, value: null }); logError(e, 'exifr parsing failed'); } }; From 14d55979724e742be1fbb88761e60c28382905ab Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 16 Dec 2022 16:59:46 +0530 Subject: [PATCH 5/6] log extension when exif parsing fails --- src/components/PhotoViewer/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/PhotoViewer/index.tsx b/src/components/PhotoViewer/index.tsx index 8c13c627e..1b97210ad 100644 --- a/src/components/PhotoViewer/index.tsx +++ b/src/components/PhotoViewer/index.tsx @@ -9,7 +9,11 @@ import { import { EnteFile } from 'types/file'; import constants from 'utils/strings/constants'; import exifr from 'exifr'; -import { downloadFile, copyFileToClipboard } from 'utils/file'; +import { + downloadFile, + copyFileToClipboard, + getFileExtension, +} from 'utils/file'; import { livePhotoBtnHTML } from 'components/LivePhotoBtn'; import { logError } from 'utils/sentry'; @@ -449,7 +453,8 @@ function PhotoViewer(props: Iprops) { } } catch (e) { setExif({ key: file.src, value: null }); - logError(e, 'exifr parsing failed'); + const fileExtension = getFileExtension(file.metadata.title); + logError(e, 'exifr parsing failed', { extension: fileExtension }); } }; From 4c0e208def0c08e05177a4258ff8cf02b193f92b Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 16 Dec 2022 17:02:11 +0530 Subject: [PATCH 6/6] remove console logs --- src/components/PhotoViewer/FileInfo/index.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/PhotoViewer/FileInfo/index.tsx b/src/components/PhotoViewer/FileInfo/index.tsx index 5557225d4..b237844ec 100644 --- a/src/components/PhotoViewer/FileInfo/index.tsx +++ b/src/components/PhotoViewer/FileInfo/index.tsx @@ -88,9 +88,6 @@ export function FileInfo({ const closeExif = () => setShowExif(false); useEffect(() => { - console.log('file.metadata', file?.metadata); - console.log('location', location); - if (!location && file && file.metadata) { if (file.metadata.longitude || file.metadata.longitude === 0) { setLocation({ @@ -102,8 +99,6 @@ export function FileInfo({ }, [file]); useEffect(() => { - console.log('exif', exif); - console.log('location', location); if (!location && exif) { const exifLocation = getEXIFLocation(exif); if (exifLocation.latitude || exifLocation.latitude === 0) {