Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Cleanup

Manav Rathifcf06cff5786
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 837cce4d95..fd2b0ca0a3 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -112,7 +112,20 @@ const FileViewer: React.FC<FileViewerProps> = ({
pswpRef.current?.closeIfNeeded();
pswpRef.current = undefined;
};
- // TODO(PS): This is missing files, initialIndex, disableDownload,
+ // The hook is missing dependencies; this is intentional - we don't want
+ // to recreate the PhotoSwipe dialog when these dependencies change.
+ //
+ // - Updates to initialIndex can be safely ignored: they don't matter,
+ // only their initial value at the time of open mattered.
+ //
+ // - Updates to disableDownload are not expected after open. We could've
+ // also added it to the dependencies array, not adding it was a more
+ // conservative choice to be on the safer side and trigger too few
+ // instead of too many updates.
+ //
+ // - Updates to files matter, but these are conveyed separately.
+ // TODO(PS):
+ //
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, onClose, handleViewInfo]);
diff --git a/web/packages/gallery/components/viewer/data-source.ts b/web/packages/gallery/components/viewer/data-source.ts
index 1c27344a0e..9a0415e4bd 100644
--- a/web/packages/gallery/components/viewer/data-source.ts
+++ b/web/packages/gallery/components/viewer/data-source.ts
@@ -378,15 +378,16 @@ const withDimensions = (imageURL: string): Promise<Partial<ItemData>> =>
* as the user swipes through the file viewer, we extract its exif data using
* {@link updateFileInfoExifIfNeeded}.
*
- * Then, if the user were to open the file info sidebar for that particular file
- * again, the associated exif data will be returned by this function. Since the
- * happy path is for synchronous use in a React component, this function
- * synchronously returns the cached value (and the callback is never invoked).
+ * Then if the user were to open the file info sidebar for that particular file,
+ * the associated exif data will be returned by this function. Since the happy
+ * path is for synchronous use in a React component, this function synchronously
+ * returns the cached value (and the callback is never invoked).
*
- * In rare cases, it is possible that this function gets called before
- * {@link updateFileInfoExifIfNeeded} has completed, the function will
- * synchronously return `undefined`, and then later call the provided
- * {@link observer} once the extraction results are available.
+ * The user can open the file info sidebar before the original has been fetched,
+ * so it is possible that this function gets called before
+ * {@link updateFileInfoExifIfNeeded} has completed. In such cases, this
+ * function will synchronously return `undefined`, and then later call the
+ * provided {@link observer} once the extraction results are available.
*/
export const fileInfoExifForFile = (
file: EnteFile,
@@ -409,9 +410,11 @@ export const fileInfoExifForFile = (
* that are made after exif data has already been extracted.
*
* If required, it will extract the exif data from the file, massage it to a
- * form suitable for use by {@link FileInfo}, and stash it in its caches.
+ * form suitable for use by {@link FileInfo}, and stash it in its caches, and
+ * notify the most recent observer for that file attached via
+ * {@link fileInfoExifForFile}.
*
- * @see {@link forgetExifForItemData}.
+ * See also {@link forgetExifForItemData}.
*/
export const updateFileInfoExifIfNeeded = async (itemData: ItemData) => {
const { fileID, fileType, imageURL } = itemData;
diff --git a/web/packages/gallery/services/download.ts b/web/packages/gallery/services/download.ts
index d7eb4dadb7..c201928c2a 100644
--- a/web/packages/gallery/services/download.ts
+++ b/web/packages/gallery/services/download.ts
@@ -52,7 +52,7 @@ export interface LoadedLivePhotoSourceURL {
*/
export interface RenderableSourceURLs {
url: string | LivePhotoSourceURL | LoadedLivePhotoSourceURL;
- originalImageURL: string | undefined;
+ originalImageURL?: string | undefined;
type: "normal" | "livePhoto";
/**
* `true` if there is potential conversion that can still be applied.