Skip to content

armgit / ente

Public Imported from GitHub
0

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

wip

Manav Rathi113a949a4bb6
diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts
index 893ff0c863..4b6d2a92ea 100644
--- a/web/apps/photos/src/services/face/indexer.ts
+++ b/web/apps/photos/src/services/face/indexer.ts
@@ -69,6 +69,8 @@ class FaceIndexer {
this.tick();
}
+ /* TODO-ML(MR): This code is not currently in use */
+
/**
* A promise for the lazily created singleton {@link FaceIndexerWorker} remote
* exposed by this module.
@@ -231,17 +233,22 @@ export const setIsFaceIndexingEnabled = async (enabled: boolean) => {
* @param count Limit the resulting list of files to {@link count}.
*/
export const getFilesToIndex = async (userID: number, count: number) => {
- const localFiles = await getLocalFiles();
const indexableTypes = [FILE_TYPE.IMAGE, FILE_TYPE.LIVE_PHOTO];
- const indexableFiles = localFiles.filter(
- (f) =>
- f.ownerID == userID && indexableTypes.includes(f.metadata.fileType),
- );
+ const isIndexable = (f: EnteFile) =>
+ f.ownerID == userID && indexableTypes.includes(f.metadata.fileType);
- const filesByID = new Map(indexableFiles.map((f) => [f.id, f]));
+ const normalFiles = await getLocalFiles("normal");
+ const hiddenFiles = await getLocalFiles("hidden");
+ const indexableNormalFiles = normalFiles.filter(isIndexable);
+ const indexableHiddenFiles = hiddenFiles.filter(isIndexable);
+
+ const normalFilesByID = new Map(indexableNormalFiles.map((f) => [f.id, f]));
+ const hiddenFilesByID = new Map(indexableHiddenFiles.map((f) => [f.id, f]));
await syncWithLocalIndexableFileIDs([...filesByID.keys()]);
const fileIDsToIndex = await indexableFileIDs(count);
- return fileIDsToIndex.map((id) => ensure(filesByID.get(id)));
+ return fileIDsToIndex.map((id) =>
+ ensure(normalFilesByID.get(id) ?? hiddenFilesByID.get(id)),
+ );
};
diff --git a/web/apps/photos/src/services/fileService.ts b/web/apps/photos/src/services/fileService.ts
index 83bd505c95..a3aa90ab04 100644
--- a/web/apps/photos/src/services/fileService.ts
+++ b/web/apps/photos/src/services/fileService.ts
@@ -32,6 +32,17 @@ const ENDPOINT = getEndpoint();
const FILES_TABLE = "files";
const HIDDEN_FILES_TABLE = "hidden-files";
+/**
+ * Return all files that we know about locally, both "normal" and "hidden".
+ */
+export const getAllLocalFiles = async () =>
+ [].concat(await getLocalFiles("normal"), await getLocalFiles("hidden"));
+
+/**
+ * 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.
+ */
export const getLocalFiles = async (type: "normal" | "hidden" = "normal") => {
const tableName = type === "normal" ? FILES_TABLE : HIDDEN_FILES_TABLE;
const files: Array<EnteFile> =
@@ -64,12 +75,6 @@ const setLocalFiles = async (type: "normal" | "hidden", files: EnteFile[]) => {
}
};
-export const getAllLocalFiles = async () => {
- const normalFiles = await getLocalFiles("normal");
- const hiddenFiles = await getLocalFiles("hidden");
- return [...normalFiles, ...hiddenFiles];
-};
-
export const syncFiles = async (
type: "normal" | "hidden",
collections: Collection[],