From 5e4707b69561dc1f2d708dbd5e568a7259ee1509 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 21 Feb 2025 09:36:10 +0530 Subject: [PATCH] ann --- web/apps/photos/src/components/PhotoFrame.tsx | 1 + .../gallery/components/viewer/data-source.ts | 9 +++--- .../gallery/components/viewer/photoswipe.ts | 29 +++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx index 469ef5521f..390746968a 100644 --- a/web/apps/photos/src/components/PhotoFrame.tsx +++ b/web/apps/photos/src/components/PhotoFrame.tsx @@ -533,6 +533,7 @@ const PhotoFrame = ({ /* @ts-ignore TODO(PS): test */ open={open5} onClose={handleClose} + user={galleryContext.user ?? undefined} files={files} initialIndex={currentIndex} {...{ diff --git a/web/packages/gallery/components/viewer/data-source.ts b/web/packages/gallery/components/viewer/data-source.ts index 50f234d8ea..2d215deca3 100644 --- a/web/packages/gallery/components/viewer/data-source.ts +++ b/web/packages/gallery/components/viewer/data-source.ts @@ -3,16 +3,15 @@ import { downloadManager, type LivePhotoSourceURL, } from "@/gallery/services/download"; -import type { EnteFile } from "@/media/file"; -import type { ParsedMetadata } from "@/media/file-metadata"; -import { FileType } from "@/media/file-type"; -import { ensureString } from "@/utils/ensure"; -// TODO(PS): import { extractRawExif, parseExif, type RawExifTags, } from "@/gallery/services/exif"; +import type { EnteFile } from "@/media/file"; +import type { ParsedMetadata } from "@/media/file-metadata"; +import { FileType } from "@/media/file-type"; +import { ensureString } from "@/utils/ensure"; /** * This is a subset of the fields expected by PhotoSwipe itself (see the diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts index 85d9b21fdc..e991e9cedf 100644 --- a/web/packages/gallery/components/viewer/photoswipe.ts +++ b/web/packages/gallery/components/viewer/photoswipe.ts @@ -34,16 +34,34 @@ if (process.env.NEXT_PUBLIC_ENTE_WIP_PS5) { // PhotoSwipe = require("./ps5/dist/photoswipe.esm.js").default; } -type FileViewerPhotoSwipeOptions = FileViewerProps & { +type FileViewerPhotoSwipeOptions = { /** * Called when the file viewer is closed. */ onClose: () => void; + /** + * Called whenever the slide changes to obtain the derived data for the file + * that is about to be displayed. + */ + onAnnotate: (file: EnteFile) => FileViewerFileAnnotation; /** * Called when the user activates the info action on a file. */ onViewInfo: (file: EnteFile) => void; -}; +} & Pick; + +/** + * Derived data for a file that is needed to display the file viewer controls + * etc associated with the file. + * + * This is recomputed each time the slide changes. + */ +interface FileViewerFileAnnotation { + /** + * `true` if this file is owned by the logged in user (if any). + */ + isOwnFile: boolean; +} /** * A wrapper over {@link PhotoSwipe} to tailor its interface for use by our file @@ -94,12 +112,19 @@ export class FileViewerPhotoSwipe { * - "auto-hidden" if controls were hidden by us because of inactivity. */ private lastActivityDate: Date | "auto-hidden" | "already-hidden"; + /** + * Derived data about the currently displayed file. + * + * This is recomputed each time the slide changes. + */ + // private activeFileAnnotation; constructor({ files, initialIndex, disableDownload, onClose, + onAnnotate, onViewInfo, }: FileViewerPhotoSwipeOptions) { this.files = files;