π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use
Manav Rathi6df16159d0a2
diff --git a/web/packages/new/photos/services/files.ts b/web/packages/new/photos/services/files.tsindex 10366319a6..eab9cc3cd1 100644--- a/web/packages/new/photos/services/files.ts+++ b/web/packages/new/photos/services/files.ts@@ -1,6 +1,5 @@import { blobCache } from "ente-base/blob-cache";import { dateFromEpochMicroseconds } from "ente-base/date";-import { isDevBuild } from "ente-base/env";import log from "ente-base/log";import { apiURL } from "ente-base/origins";import type { Collection } from "ente-media/collection";@@ -19,29 +18,27 @@ import {getCollectionLastSyncTime,setCollectionLastSyncTime,} from "./collections";-import { savedNormalFiles } from "./photos-fdb";+import { savedFiles, savedHiddenFiles, savedNormalFiles } from "./photos-fdb";const FILES_TABLE = "files";const HIDDEN_FILES_TABLE = "hidden-files";/*** Return all files that we know about locally, both "normal" and "hidden".+ *+ * Deprecated. Use {@link savedFiles} instead.*/-export const getAllLocalFiles = async () =>- (await getLocalFiles("normal")).concat(await getLocalFiles("hidden"));+export const getAllLocalFiles = savedFiles;/*** Return all files that we know about locally. By default it returns only* "normal" (i.e. non-"hidden") files, but it can be passed the {@link type}* "hidden" to get it to instead return hidden files that we know about locally.+ *+ * Deprecated. Use {@link savedNormalFiles} or {@link savedHiddenFiles} instead.*/-export const getLocalFiles = async (type: "normal" | "hidden" = "normal") => {- if (type == "normal" && isDevBuild) return savedNormalFiles();- const tableName = type == "normal" ? FILES_TABLE : HIDDEN_FILES_TABLE;- const files: EnteFile[] =- (await localForage.getItem<EnteFile[]>(tableName)) ?? [];- return files;-};+export const getLocalFiles = async (type: "normal" | "hidden" = "normal") =>+ type == "normal" ? savedNormalFiles() : savedHiddenFiles();/*** Update the files that we know about locally.diff --git a/web/packages/new/photos/services/photos-fdb.ts b/web/packages/new/photos/services/photos-fdb.tsindex 687dff0fbe..30e0425730 100644--- a/web/packages/new/photos/services/photos-fdb.ts+++ b/web/packages/new/photos/services/photos-fdb.ts@@ -111,10 +111,9 @@ export const saveTrashItemCollectionKeys = (cks: TrashItemCollectionKey[]) =>* {@link savedNormalFiles} or {@link savedHiddenFiles} to obtain them; this* method is only a convenience to concatenate the two.*/-export const savedFiles = async (): Promise<EnteFile[]> => {- await Promise.resolve(1);- throw new Error("TODO(RE)");-};+export const savedFiles = async (): Promise<EnteFile[]> =>+ Promise.all([savedNormalFiles(), savedHiddenFiles()]).then((f) => f.flat());+/*** Return all normal (non-hidden) files present in our local database.*@@ -136,3 +135,12 @@ export const savedNormalFiles = async (): Promise<EnteFile[]> =>// not be the most optimal choice in the future, so (a) use it sparingly,// and (b) mark all such cases with the title of this note.(await localForage.getItem<EnteFile[]>("files")) ?? [];++/**+ * Return all hidden files present in our local database.+ *+ * Use {@link saveNormalFiles} to update the database.+ */+export const savedHiddenFiles = async (): Promise<EnteFile[]> =>+ // See: [Note: Avoiding Zod parsing for large DB arrays]+ (await localForage.getItem<EnteFile[]>("hidden-files")) ?? [];