π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[locker][web] Fix Locker favorites ownership lookup
Vishnu Mohandas1bea2a226105
diff --git a/web/apps/locker/src/services/remote-cache.ts b/web/apps/locker/src/services/remote-cache.tsindex e41d8292aa..5f1a2333fe 100644--- a/web/apps/locker/src/services/remote-cache.ts+++ b/web/apps/locker/src/services/remote-cache.ts@@ -121,9 +121,11 @@ export const getCollectionRecord = (collectionID: number) =>export const getCollectionRecords = () => [...encryptedCollections.values()];-export const findCollectionByType = (type: string) =>+export const findCollectionByType = (type: string, ownerID?: number) =>[...encryptedCollections.values()].find(- (candidate) => candidate.type === type,+ (candidate) =>+ candidate.type === type &&+ (ownerID === undefined || candidate.ownerID === ownerID),);export const updateCollectionShareesInCache = (diff --git a/web/apps/locker/src/services/remote.ts b/web/apps/locker/src/services/remote.tsindex a3162a1876..e356f9f21c 100644--- a/web/apps/locker/src/services/remote.ts+++ b/web/apps/locker/src/services/remote.ts@@ -943,8 +943,10 @@ export const createCollection = async (};const ensureUncategorizedCollection = async (masterKey: string) => {+ const currentUserID = ensureLocalUser().id;return ensureUncategorizedCollectionWithDeps(masterKey, {- findCollectionByType,+ findCollectionByType: (type) =>+ findCollectionByType(type, currentUserID),refetchCollections: async (masterKey) => {await fetchLockerData(masterKey);},@@ -952,8 +954,10 @@ const ensureUncategorizedCollection = async (masterKey: string) => {};const ensureFavoritesCollection = async (masterKey: string) => {+ const currentUserID = ensureLocalUser().id;return ensureFavoritesCollectionWithDeps(masterKey, {- findCollectionByType,+ findCollectionByType: (type) =>+ findCollectionByType(type, currentUserID),refetchCollections: async (resolvedMasterKey) => {await fetchLockerData(resolvedMasterKey);},@@ -1063,12 +1067,16 @@ export const setItemImportant = async (shouldBeImportant: boolean,masterKey: string,): Promise<boolean> => {+ const currentUserID = ensureLocalUser().id;const currentCollectionIDs = getCollectionIDsForFile(fileID);if (currentCollectionIDs.length === 0) {throw new Error(`File ${fileID} not found in cache`);}- const favoritesCollection = findCollectionByType("favorites");+ const favoritesCollection = findCollectionByType(+ "favorites",+ currentUserID,+ );if (!shouldBeImportant && !favoritesCollection) {return false;}@@ -1092,7 +1100,7 @@ export const setItemImportant = async (}await updateItemCollectionsWithDeps(fileID, nextCollectionIDs, {- currentUserID: ensureLocalUser().id,+ currentUserID,masterKey,deps: createCollectionMutationDeps(),});