Skip to content

armgit / ente

Public Imported from GitHub
0

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

memo

Manav Rathi6b04ef69ed7e
diff --git a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx
index a0f86e8e74..74110b5822 100644
--- a/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionOptions/index.tsx
@@ -90,34 +90,40 @@ const CollectionOptions = (props: CollectionOptionsProps) => {
* Return a new function by wrapping an async function in an error handler,
* and syncing with remote on completion.
*/
- const wrap = async (f: () => Promise<void>) => {
- return async () => {
- try {
- await f();
- } catch (e) {
- handleError(e);
- } finally {
- syncWithRemote(false, true);
- }
- };
- };
+ const wrap = useCallback(
+ async (f: () => Promise<void>) => {
+ return async () => {
+ try {
+ await f();
+ } catch (e) {
+ handleError(e);
+ } finally {
+ syncWithRemote(false, true);
+ }
+ };
+ },
+ [handleError, syncWithRemote],
+ );
/**
* Variant of {@link wrap} that also shows the global loading bar.
*/
- const wrapLoading = async (f: () => Promise<void>) => {
- return async () => {
- startLoading();
- try {
- await f();
- } catch (e) {
- handleError(e);
- } finally {
- syncWithRemote(false, true);
- finishLoading();
- }
- };
- };
+ const wrapLoading = useCallback(
+ async (f: () => Promise<void>) => {
+ return async () => {
+ startLoading();
+ try {
+ await f();
+ } catch (e) {
+ handleError(e);
+ } finally {
+ syncWithRemote(false, true);
+ finishLoading();
+ }
+ };
+ },
+ [handleError, syncWithRemote, startLoading, finishLoading],
+ );
const showRenameCollectionModal = () => {
setCollectionNamerAttributes({