wip
This commit is contained in:
@@ -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)),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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[],
|
||||
|
||||
Reference in New Issue
Block a user