π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Abstract
Manav Rathi5864648c24d5
diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsxindex bed1d3c5c4..3f25cd1906 100644--- a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx+++ b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx@@ -27,7 +27,7 @@ import { t } from "i18next";import { AppContext } from "pages/_app";import { GalleryContext } from "pages/gallery";import type { Dispatch, SetStateAction } from "react";-import { useContext, useRef, useState } from "react";+import { useCallback, useContext, useRef, useState } from "react";import { Trans } from "react-i18next";import * as CollectionAPI from "services/collectionService";import * as TrashService from "services/trashService";@@ -106,21 +106,28 @@ const CollectionOptions = (props: CollectionOptionsProps) => {setCollectionSortOrderMenuView(false);};+ const handleError = useCallback(+ (e: unknown) => {+ log.error("Collection action failed", e);+ setDialogMessage({+ title: t("ERROR"),+ content: t("UNKNOWN_ERROR"),+ close: { variant: "critical" },+ });+ },+ [setDialogMessage],+ );+/*** Return a new function that shows an generic error dialog if the original* function throws.*/const wrapError = async (f: () => Promise<void>) => {- return () => {+ return async () => {try {await f();} catch (e) {- log.error("Collection action failed", e);- setDialogMessage({- title: t("ERROR"),- content: t("UNKNOWN_ERROR"),- close: { variant: "critical" },- });+ handleError(e);}};};@@ -132,16 +139,11 @@ const CollectionOptions = (props: CollectionOptionsProps) => {const wrapErrorAndSyncWithRemote = async (f: (...args: any) => Promise<void>,) => {- return (...args: any) => {+ return async (...args: any) => {try {await f();} catch (e) {- log.error("Collection action failed", e);- setDialogMessage({- title: t("ERROR"),- content: t("UNKNOWN_ERROR"),- close: { variant: "critical" },- });+ handleError(e);} finally {syncWithRemote(false, true);}@@ -155,17 +157,12 @@ const CollectionOptions = (props: CollectionOptionsProps) => {const wrapErrorAndSyncWithRemoteLoading = async (f: () => Promise<void>,) => {- return () => {+ return async () => {startLoading();try {await f();} catch (e) {- log.error("Collection action failed", e);- setDialogMessage({- title: t("ERROR"),- content: t("UNKNOWN_ERROR"),- close: { variant: "critical" },- });+ handleError(e);} finally {syncWithRemote(false, true);finishLoading();