From 8bf88c205970b0adbff30cc8f86712f7cd740fc8 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 26 Jul 2024 12:46:02 +0530 Subject: [PATCH] Full listing --- .../components/PhotoViewer/FileInfo/index.tsx | 89 ++++++++++--------- .../src/components/PhotoViewer/index.tsx | 10 +-- 2 files changed, 52 insertions(+), 47 deletions(-) diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx index 81ba8e65b7..e231929db4 100644 --- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx +++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx @@ -50,17 +50,17 @@ export interface FileInfoExif { } interface FileInfoProps { - shouldDisableEdits?: boolean; showInfo: boolean; handleCloseInfo: () => void; - file: EnteFile; + closePhotoViewer: () => void; + file: EnteFile | undefined; exif: FileInfoExif | undefined; + shouldDisableEdits?: boolean; scheduleUpdate: () => void; refreshPhotoswipe: () => void; fileToCollectionsMap?: Map; collectionNameMap?: Map; showCollectionChips: boolean; - closePhotoViewer: () => void; } export const FileInfo: React.FC = ({ @@ -100,8 +100,8 @@ export const FileInfo: React.FC = ({ }; } } - return exif.parsed.location; - }, [file]); + return exif?.parsed.location; + }, [file, exif]); useEffect(() => { setParsedExif(exif ? parseFileInfoExif(exif) : undefined); @@ -217,7 +217,7 @@ export const FileInfo: React.FC = ({ caption={ typeof exif === "undefined" ? ( - ) : exif !== null ? ( + ) : exif !== null /* TODO */ ? ( setOpenRawExif(true)} sx={{ @@ -280,7 +280,7 @@ export const FileInfo: React.FC = ({ open={openRawExif} onClose={() => setOpenRawExif(false)} onInfoClose={handleCloseInfo} - tags={exif.tags} + tags={exif?.tags} fileName={file.metadata.title} /> @@ -482,10 +482,25 @@ const RawExif: React.FC = ({ onInfoClose(); }; - const items: [string, string, string, string] = Object.entries(tags) - .map((namespace, namespaceTags) => { - return Object.entries(namespaceTags).map((tagName, tag) => { - return [`${namespace}:${tagName}`, namespace, tagName, tag.description]; + const items: (readonly [string, string, string, string])[] = Object.entries( + tags, + ) + .map(([namespace, namespaceTags]) => { + return Object.entries(namespaceTags).map(([tagName, tag]) => { + const key = `${namespace}:${tagName}`; + let description = "<...>"; + if (typeof tag == "string") { + description = tag; + } else if (typeof tag == "number") { + description = `${tag}`; + } else if ( + tag && + typeof tag == "object" && + "description" in tag + ) { + description = tag.description; + } + return [key, namespace, tagName, description] as const; }); }) .flat(); @@ -505,38 +520,28 @@ const RawExif: React.FC = ({ } /> - {items.map(([key, namespace, tagName, value]) => - value ? ( - - - - {tagName} - - - {namespace} - - - - {parseExifValue(value)} + {items.map(([key, namespace, tagName, description]) => ( + + + + {tagName} - - ) : ( - - ), - )} + + {namespace} + + + + {description} + + + ))} ); diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsx index 4d623992aa..5c50233f21 100644 --- a/web/apps/photos/src/components/PhotoViewer/index.tsx +++ b/web/apps/photos/src/components/PhotoViewer/index.tsx @@ -929,21 +929,21 @@ function PhotoViewer(props: Iprops) {