Skip to content

armgit / ente

Public Imported from GitHub
0

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

Better state during initial load

Manav Rathi3f9a7e08a143
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index 07b8afe5cd..9aa2c4338c 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -490,8 +490,10 @@ const getMLStatus = async (): Promise<MLStatus> => {
const state = await (await worker()).state;
if (state == "indexing" || state == "fetching") {
phase = state;
+ } else if (state == "init" || indexableCount > 0) {
+ phase = "scheduled";
} else {
- phase = indexableCount > 0 ? "scheduled" : "done";
+ phase = "done";
}
return {
diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.ts
index 0823a5806a..d6e2e17a43 100644
--- a/web/packages/new/photos/services/ml/worker.ts
+++ b/web/packages/new/photos/services/ml/worker.ts
@@ -43,6 +43,7 @@ import type { CLIPMatches, MLWorkerDelegate } from "./worker-types";
/**
* A rough hint at what the worker is up to.
*
+ * - "init": Worker has been created but hasn't done anything yet.
* - "idle": Not doing anything
* - "tick": Transitioning to a new state
* - "indexing": Indexing
@@ -52,7 +53,7 @@ import type { CLIPMatches, MLWorkerDelegate } from "./worker-types";
* data for more than 50% of the files that we requested from it in the last
* fetch during indexing.
*/
-export type WorkerState = "idle" | "tick" | "indexing" | "fetching";
+export type WorkerState = "init" | "idle" | "tick" | "indexing" | "fetching";
const idleDurationStart = 5; /* 5 seconds */
const idleDurationMax = 16 * 60; /* 16 minutes */
@@ -92,7 +93,7 @@ interface IndexableItem {
*/
export class MLWorker {
/** The last known state of the worker. */
- public state: WorkerState = "idle";
+ public state: WorkerState = "init";
private electron: ElectronMLWorker | undefined;
private delegate: MLWorkerDelegate | undefined;