Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prep for clustering updates

Manav Rathie8b692b5ad60
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index 5af8e3b240..0f6b32aed3 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -100,9 +100,7 @@ const worker = () =>
const createComlinkWorker = async () => {
const electron = ensureElectron();
- const delegate = {
- workerDidProcessFileOrIdle,
- };
+ const delegate = { workerDidUpdateStatus };
// Obtain a message port from the Electron layer.
const messagePort = await createMLWorker(electron);
@@ -593,7 +591,7 @@ const setInterimScheduledStatus = () => {
setMLStatusSnapshot({ phase: "scheduled", nSyncedFiles, nTotalFiles });
};
-const workerDidProcessFileOrIdle = throttled(updateMLStatusSnapshot, 2000);
+const workerDidUpdateStatus = throttled(updateMLStatusSnapshot, 2000);
/**
* A function that can be used to subscribe to updates to {@link Person}s.
diff --git a/web/packages/new/photos/services/ml/worker-types.ts b/web/packages/new/photos/services/ml/worker-types.ts
index 446986b8ef..b12598d52b 100644
--- a/web/packages/new/photos/services/ml/worker-types.ts
+++ b/web/packages/new/photos/services/ml/worker-types.ts
@@ -3,15 +3,16 @@
*/
/**
- * Callbacks invoked by the worker at various points in the indexing pipeline to
- * notify the main thread of events it might be interested in.
+ * Callbacks invoked by the worker at various points in the indexing and
+ * clustering pipeline to notify the main thread of events it might be
+ * interested in.
*/
export interface MLWorkerDelegate {
/**
- * Called whenever the worker processes a file during indexing (either
- * successfully or with errors), or when in goes into the "idle" state.
+ * Called whenever the worker does some action that might need the UI state
+ * indicating the indexing or clustering status to be updated.
*/
- workerDidProcessFileOrIdle: () => void;
+ workerDidUpdateStatus: () => void;
}
/**
diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.ts
index e668ed070c..e43af4ccea 100644
--- a/web/packages/new/photos/services/ml/worker.ts
+++ b/web/packages/new/photos/services/ml/worker.ts
@@ -242,7 +242,7 @@ export class MLWorker {
this.state = "idle";
this.idleDuration = Math.min(this.idleDuration * 2, idleDurationMax);
this.idleTimeout = setTimeout(scheduleTick, this.idleDuration * 1000);
- this.delegate?.workerDidProcessFileOrIdle();
+ this.delegate?.workerDidUpdateStatus();
}
/** Return the next batch of items to backfill (if any). */
@@ -342,7 +342,7 @@ const indexNextBatch = async (
await Promise.race(tasks);
// Let the main thread now we're doing something.
- delegate?.workerDidProcessFileOrIdle();
+ delegate?.workerDidUpdateStatus();
// Let us drain the microtask queue. This also gives a chance for other
// interactive tasks like `clipMatches` to run.