π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Close
Manav Rathi931d7c851351
diff --git a/web/packages/gallery/components/viewer/data-source.ts b/web/packages/gallery/components/viewer/data-source.tsindex e85cdc65e9..e8f588b0fe 100644--- a/web/packages/gallery/components/viewer/data-source.ts+++ b/web/packages/gallery/components/viewer/data-source.ts@@ -168,14 +168,26 @@ export const itemDataForFile = (file: EnteFile, needsRefresh: () => void) => {};/**- * Reset any failure reasons for the given {@link file}.+ * Forget item data for the given {@link file} if its fetch had failed.*- * This is called when the user moves away from a slide, so that when the come- * back the next time, the entire process is retried.+ * This is called when the user moves away from a slide so that we attempt a+ * full retry when they come back the next time.*/-export const resetFailuresForFile = (file: EnteFile) => {- if (_state.itemDataByFileID.get(file.id)?.fetchFailed) {- _state.itemDataByFileID.delete(file.id);+export const forgetFailedItemDataForFile = (file: EnteFile) =>+ forgetFailedItemDataForFileID(file.id);++/**+ * Forget item data for the all files whose fetch had failed.+ *+ * This is called when the user closes the file viewer so that we attempt a full+ * retry when they reopen the viewer the next time.+ */+export const forgetFailedItems = () =>+ [..._state.itemDataByFileID.keys()].forEach(forgetFailedItemDataForFileID);++const forgetFailedItemDataForFileID = (fileID: number) => {+ if (_state.itemDataByFileID.get(fileID)?.fetchFailed) {+ _state.itemDataByFileID.delete(fileID);}};diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 4610762bcb..62bc367e38 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -4,7 +4,11 @@import log from "@/base/log";import type { EnteFile } from "@/media/file";import { t } from "i18next";-import { itemDataForFile, resetFailuresForFile } from "./data-source";+import {+ forgetFailedItemDataForFile,+ forgetFailedItems,+ itemDataForFile,+} from "./data-source";import type { FileViewerProps } from "./FileViewer";import { createPSRegisterElementIconHTML } from "./icons";@@ -254,7 +258,7 @@ export class FileViewerPhotoSwipe {// more than 2 slides and then back, or if they reopen the viewer.//// See: [Note: File viewer error handling]- resetFailuresForFile(currentFile());+ forgetFailedItemDataForFile(currentFile());// Pause the video element, if any, when we move away from the// slide.@@ -273,10 +277,11 @@ export class FileViewerPhotoSwipe {}});- // The user did some action within the file viewer to close it.- pswp.on("close", () => {- // Clear intervals.+ // The PhotoSwipe dialog has being closed and the animations have+ // completed.+ pswp.on("destroy", () => {this.clearAutoHideIntervalIfNeeded();+ forgetFailedItems();// Let our parent know that we have been closed.onClose();});@@ -295,6 +300,7 @@ export class FileViewerPhotoSwipe {pswp.ui.registerElement({name: "error",order: 6,+ // TODO(PS): Change color?html: createPSRegisterElementIconHTML("error"),onInit: (errorElement, pswp) => {pswp.on("change", () => {@@ -353,7 +359,6 @@ export class FileViewerPhotoSwipe {// closed internally (e.g. the user activated the close button within// the file viewer), then PhotoSwipe will ignore this extra close.this.pswp.close();- this.clearAutoHideIntervalIfNeeded();}updateFiles(files: EnteFile[]) {