This commit is contained in:
Manav Rathi
2025-02-21 09:36:10 +05:30
parent fd0c2866a2
commit 5e4707b695
3 changed files with 32 additions and 7 deletions

View File

@@ -533,6 +533,7 @@ const PhotoFrame = ({
/* @ts-ignore TODO(PS): test */
open={open5}
onClose={handleClose}
user={galleryContext.user ?? undefined}
files={files}
initialIndex={currentIndex}
{...{

View File

@@ -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

View File

@@ -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<FileViewerProps, "files" | "initialIndex" | "disableDownload">;
/**
* 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;