Skip to content

armgit / ente

Public Imported from GitHub
0

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

sigh

Manav Rathide9cad09c4ee
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx
index 959395833e..c779b8412d 100644
--- a/web/apps/photos/src/components/PhotoFrame.tsx
+++ b/web/apps/photos/src/components/PhotoFrame.tsx
@@ -276,6 +276,7 @@ const PhotoFrame = ({
const isFavorite = favoriteFileIDs!.has(file.id);
await (isFavorite ? removeFromFavorites : addToFavorites)(
file,
+ true,
);
onMarkUnsyncedFavoriteUpdate(file.id, !isFavorite);
}
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 2e9250b67a..211021c33b 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -139,11 +139,17 @@ export const createFavoritesCollection = () => {
return createCollection(FAVORITE_COLLECTION_NAME, CollectionType.favorites);
};
-export const addToFavorites = async (file: EnteFile) => {
- await addMultipleToFavorites([file]);
+export const addToFavorites = async (
+ file: EnteFile,
+ disableOldWorkaround?: boolean,
+) => {
+ await addMultipleToFavorites([file], disableOldWorkaround);
};
-export const addMultipleToFavorites = async (files: EnteFile[]) => {
+export const addMultipleToFavorites = async (
+ files: EnteFile[],
+ disableOldWorkaround?: boolean,
+) => {
try {
let favCollection = await getFavCollection();
if (!favCollection) {
@@ -152,10 +158,19 @@ export const addMultipleToFavorites = async (files: EnteFile[]) => {
await addToCollection(favCollection, files);
} catch (e) {
log.error("failed to add to favorite", e);
+ // Old code swallowed the error here. This isn't good, but to
+ // avoid changing existing behaviour only new code will set the
+ // disableOldWorkaround flag to instead rethrow it.
+ //
+ // TODO: Migrate old code, remove this flag, always throw.
+ if (disableOldWorkaround) throw e;
}
};
-export const removeFromFavorites = async (file: EnteFile) => {
+export const removeFromFavorites = async (
+ file: EnteFile,
+ disableOldWorkaround?: boolean,
+) => {
try {
const favCollection = await getFavCollection();
if (!favCollection) {
@@ -164,6 +179,8 @@ export const removeFromFavorites = async (file: EnteFile) => {
await removeFromCollection(favCollection.id, [file]);
} catch (e) {
log.error("remove from favorite failed", e);
+ // TODO: See disableOldWorkaround in addMultipleToFavorites.
+ if (disableOldWorkaround) throw e;
}
};