From ffc1db7369d4cbd71618cbefe2d595bbbff04bc6 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 28 Feb 2025 13:33:50 +0530 Subject: [PATCH] err 1 --- .../gallery/components/viewer/FileViewer.tsx | 12 ++++++++++-- web/packages/gallery/components/viewer/photoswipe.ts | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx index 44d51eab81..5aefa1cb72 100644 --- a/web/packages/gallery/components/viewer/FileViewer.tsx +++ b/web/packages/gallery/components/viewer/FileViewer.tsx @@ -15,6 +15,7 @@ if (process.env.NEXT_PUBLIC_ENTE_WIP_PS5) { import { isDesktop } from "@/base/app"; import { type ModalVisibilityProps } from "@/base/components/utils/modal"; +import { useBaseContext } from "@/base/context"; import { lowercaseExtension } from "@/base/file-name"; import type { LocalUser } from "@/base/local-user"; import log from "@/base/log"; @@ -159,6 +160,8 @@ const FileViewer: React.FC = ({ onSelectPerson, onSaveEditedImageCopy, }) => { + const { onGenericError } = useBaseContext(); + // There are 3 things involved in this dance: // // 1. Us, "FileViewer". We're a React component. @@ -306,7 +309,12 @@ const FileViewer: React.FC = ({ if (!showModifyActions || !favoriteFileIDs) throw new Error("Unexpected invocation"); - await new Promise((r) => setTimeout(r, 7000)); + try { + await new Promise((r) => setTimeout(r, 3000)); + throw new Error("test"); + } catch (e) { + onGenericError(e); + } console.log({ file, annotation }); // TODO // const isFavorite = annotation.isFavorite; @@ -323,7 +331,7 @@ const FileViewer: React.FC = ({ // onMarkUnsyncedFavoriteUpdate(file.id, undefined); // }); }, - [showModifyActions, favoriteFileIDs], + [showModifyActions, onGenericError, favoriteFileIDs], ); // Initial value of delegate. diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts index d6dbd2997f..d7f63e69d3 100644 --- a/web/packages/gallery/components/viewer/photoswipe.ts +++ b/web/packages/gallery/components/viewer/photoswipe.ts @@ -90,7 +90,11 @@ export interface FileViewerPhotoSwipeDelegate { * Called when the user activates the toggle favorite action on a file. * * The toggle favorite button will be disabled for the file until the - * promise returned by this function returns settles. + * promise returned by this function returns fulfills. + * + * > Note: The caller is expected to handle any errors that occur, and + * > should not reject for foreseeable failures, otherwise the button will + * > remain in the disabled state (until the file viewer is closed). */ toggleFavorite: (annotatedFile: FileViewerAnnotatedFile) => Promise; }