From c6255931626b2c57506208c33b40f77def4eb86b Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 21 Sep 2024 09:00:26 +0530 Subject: [PATCH] Fwd --- .../Collections/CollectionOptions/index.tsx | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx index 3f25cd1906..53929ec4fd 100644 --- a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx +++ b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx @@ -122,26 +122,16 @@ const CollectionOptions = (props: CollectionOptionsProps) => { * Return a new function that shows an generic error dialog if the original * function throws. */ - const wrapError = async (f: () => Promise) => { - return async () => { - try { - await f(); - } catch (e) { - handleError(e); - } - }; - }; + const wrapError = (f: () => Promise) => () => f().catch(handleError); /** * Return a new function by wrapping an async function in an error handler, * and syncing on completion. */ - const wrapErrorAndSyncWithRemote = async ( - f: (...args: any) => Promise, - ) => { + const wrapErrorAndSync = async (f: (...args: any) => Promise) => { return async (...args: any) => { try { - await f(); + await f(...args); } catch (e) { handleError(e); } finally { @@ -151,12 +141,10 @@ const CollectionOptions = (props: CollectionOptionsProps) => { }; /** - * Variant of {@link wrapErrorAndSyncWithRemote} that also shows the global + * Variant of {@link wrapErrorAndSync} that also shows the global * loading bar. */ - const wrapErrorAndSyncWithRemoteLoading = async ( - f: () => Promise, - ) => { + const wrapErrorAndSyncLoading = async (f: () => Promise) => { return async () => { startLoading(); try {