Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web] Bulk fav: Refresh on success

Manav Rathi96378162620b
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index f5c94ffe72..db9acbfa25 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -992,7 +992,7 @@ export default function Gallery() {
setTempHiddenFileIds,
setFixCreationTimeAttributes,
setFilesDownloadProgressAttributesCreator,
- updateFavItemIds,
+ refreshFavItemIds,
);
}
clearSelection();
@@ -1120,7 +1120,7 @@ export default function Gallery() {
[],
);
- const updateFavItemIds = async () => {
+ const refreshFavItemIds = async () => {
const favItemIds = await getFavItemIds(files);
setFavItemIds(favItemIds);
};
diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts
index 916bccc836..23b4ef69ad 100644
--- a/web/apps/photos/src/utils/file/index.ts
+++ b/web/apps/photos/src/utils/file/index.ts
@@ -602,7 +602,7 @@ export const handleFileOps = async (
| ((prev: { files: EnteFile[] }) => { files: EnteFile[] }),
) => void,
setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator,
- updateFavItemIds: (ids: Set<Number>) => void,
+ refreshFavItemIds: () => void,
) => {
switch (ops) {
case FILE_OPS_TYPE.TRASH:
@@ -635,8 +635,7 @@ export const handleFileOps = async (
await changeFilesVisibility(files, ItemVisibility.visible);
break;
case FILE_OPS_TYPE.SET_FAVORITE:
- await setBulkFavorite(files);
- updateFavItemIds(new Set(files.map((f) => f.id)));
+ await setBulkFavorite(files, refreshFavItemIds);
break;
}
};
@@ -691,9 +690,13 @@ const fixTimeHelper = async (
setFixCreationTimeAttributes({ files: selectedFiles });
};
-const setBulkFavorite = async (files: EnteFile[]) => {
+const setBulkFavorite = async (
+ files: EnteFile[],
+ refreshFavItemIds: () => void,
+) => {
try {
await addMultipleToFavorites(files);
+ refreshFavItemIds();
} catch (e) {
log.error("Could not add to favorites", e);
}