Skip to content

armgit / ente

Public Imported from GitHub
0

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

revert(collection):remove-unwanted-variables

Aswin Asok68aed0131a75
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index 9813c342dd..c3b8ffa41d 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -780,8 +780,6 @@ const userOwnedEquivalentFilesByHashAndType = (
// Bridges shared favorite toggles before the remote add/move has been pulled
// into local DB.
const pendingFavoriteFilesByHashAndType = new Map<string, EnteFile>();
-let pendingUserFavoritesCollection: Collection | undefined;
-let pendingUserFavoritesCollectionPromise: Promise<Collection> | undefined;
/**
*
@@ -1873,38 +1871,19 @@ export const createUncategorizedCollection = () =>
*
* Reads local state but does not modify it. The effects are on remote.
*/
-const savedOrCreateUserFavoritesCollection = async () => {
- const favoritesCollection = await savedUserFavoritesCollection();
- if (favoritesCollection) return favoritesCollection;
-
- pendingUserFavoritesCollectionPromise ??= createFavoritesCollection()
- .then((collection) => {
- pendingUserFavoritesCollection = collection;
- return collection;
- })
- .finally(() => {
- pendingUserFavoritesCollectionPromise = undefined;
- });
-
- return pendingUserFavoritesCollectionPromise;
-};
+const savedOrCreateUserFavoritesCollection = async () =>
+ (await savedUserFavoritesCollection()) ?? createFavoritesCollection();
/**
- * Return the user's own favorites collection if present in the local database,
- * or one created during this session before the next remote pull.
+ * Return the user's own favorites collection if present in the local database.
*/
export const savedUserFavoritesCollection = async () => {
const userID = ensureLocalUser().id;
const collections = await savedCollections();
- return (
- collections.find(
- (collection) =>
- // See: [Note: User and shared favorites]
- collection.type == "favorites" && collection.owner.id == userID,
- ) ??
- (pendingUserFavoritesCollection?.owner.id == userID
- ? pendingUserFavoritesCollection
- : undefined)
+ return collections.find(
+ (collection) =>
+ // See: [Note: User and shared favorites]
+ collection.type == "favorites" && collection.owner.id == userID,
);
};