π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update
Manav Rathi5034fb4496fc
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 23230f49ce..7d73991222 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -52,6 +52,7 @@ import type { Collection } from "ente-media/collection";import { type EnteFile } from "ente-media/file";import {savedLastPublicCollectionReferralCode,+ savedPublicCollectionByKey,savedPublicCollectionFiles,} from "ente-new/albums/services/public-albums-fdb";import { verifyPublicAlbumPassword } from "ente-new/albums/services/public-collection";@@ -68,7 +69,6 @@ import { useRouter } from "next/router";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { type FileWithPath } from "react-dropzone";import {- getLocalPublicCollection,getLocalPublicCollectionPassword,getPublicCollection,getPublicCollectionUID,@@ -216,7 +216,7 @@ export default function PublicCollectionGallery() {}collectionKey.current = ck;url.current = window.location.href;- const localCollection = await getLocalPublicCollection(+ const localCollection = await savedPublicCollectionByKey(collectionKey.current,);const accessToken = t;diff --git a/web/apps/photos/src/services/publicCollectionService.ts b/web/apps/photos/src/services/publicCollectionService.tsindex 35af9787b3..c9b8765c97 100644--- a/web/apps/photos/src/services/publicCollectionService.ts+++ b/web/apps/photos/src/services/publicCollectionService.ts@@ -9,12 +9,13 @@ import type {import type { EnteFile, RemoteEnteFile } from "ente-media/file";import { decryptRemoteFile } from "ente-media/file";import {+ removePublicCollectionByKey,removePublicCollectionFiles,removePublicCollectionLastSyncTime,savedPublicCollectionFiles,savedPublicCollectionLastSyncTime,- savedPublicCollections,saveLastPublicCollectionReferralCode,+ savePublicCollection,savePublicCollectionFiles,savePublicCollectionLastSyncTime,} from "ente-new/albums/services/public-albums-fdb";@@ -22,8 +23,6 @@ import { CustomError, parseSharingErrorCodes } from "ente-shared/error";import HTTPService from "ente-shared/network/HTTPService";import localForage from "ente-shared/storage/localForage";-const PUBLIC_COLLECTIONS_TABLE = "public-collections";-// Fix this once we can trust the types.// eslint-disable-next-line @typescript-eslint/no-unnecessary-template-expressionexport const getPublicCollectionUID = (token: string) => `${token}`;@@ -56,36 +55,6 @@ export const savePublicCollectionPassword = async ();};-export const getLocalPublicCollection = async (collectionKey: string) => {- const localCollections = await savedPublicCollections();- const publicCollection =- localCollections.find(- (localSavedPublicCollection) =>- localSavedPublicCollection.key === collectionKey,- ) || null;- return publicCollection;-};--export const savePublicCollection = async (collection: Collection) => {- const publicCollections = await savedPublicCollections();- await localForage.setItem(- PUBLIC_COLLECTIONS_TABLE,- dedupeCollections([collection, ...publicCollections]),- );-};--const dedupeCollections = (collections: Collection[]) => {- const keySet = new Set([]);- return collections.filter((collection) => {- if (!keySet.has(collection.key)) {- keySet.add(collection.key);- return true;- } else {- return false;- }- });-};-export const syncPublicFiles = async (token: string,passwordToken: string,@@ -292,13 +261,7 @@ export const removePublicCollectionWithFiles = async (collectionUID: string,collectionKey: string,) => {- const publicCollections = await savedPublicCollections();- await localForage.setItem(- PUBLIC_COLLECTIONS_TABLE,- publicCollections.filter(- (collection) => collection.key !== collectionKey,- ),- );+ await removePublicCollectionByKey(collectionKey);await removePublicFiles(collectionUID);};diff --git a/web/packages/new/albums/services/public-albums-fdb.ts b/web/packages/new/albums/services/public-albums-fdb.tsindex 2b4d916133..91217655e9 100644--- a/web/packages/new/albums/services/public-albums-fdb.ts+++ b/web/packages/new/albums/services/public-albums-fdb.ts@@ -47,7 +47,7 @@ export const savePublicCollections = (collections: Collection[]) =>* @param key The collection key that can be used to identify the public album* we want from amongst all the locally saved public albums.*/-export const savedPublicCollection = async (+export const savedPublicCollectionByKey = async (collectionKey: string,): Promise<Collection | undefined> =>savedPublicCollections().then((cs) =>@@ -69,12 +69,16 @@ export const savePublicCollection = async (collection: Collection) => {};/**- * Remove a public collection from our local database.+ * Remove a public collection, identified using its collection key, from our+ * local database.+ *+ * @param key The collection key that can be used to identify the public album+ * we want to remove.*/-export const removePublicCollection = async (collection: Collection) => {+export const removePublicCollectionByKey = async (collectionKey: string) => {const collections = await savedPublicCollections();await savePublicCollections([- ...collections.filter((c) => c.id != collection.id),+ ...collections.filter((c) => c.key != collectionKey),]);};