π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Handle the idle transition in the UI
Manav Rathid7fb8cf82b5f
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.tsindex 53a57a3b73..07b8afe5cd 100644--- a/web/packages/new/photos/services/ml/index.ts+++ b/web/packages/new/photos/services/ml/index.ts@@ -89,7 +89,7 @@ const worker = () =>const createComlinkWorker = async () => {const electron = ensureElectron();const delegate = {- workerDidProcessFile,+ workerDidProcessFileOrIdle,};// Obtain a message port from the Electron layer.@@ -523,7 +523,7 @@ const setInterimScheduledStatus = () => {setMLStatusSnapshot({ phase: "scheduled", nSyncedFiles, nTotalFiles });};-const workerDidProcessFile = throttled(updateMLStatusSnapshot, 2000);+const workerDidProcessFileOrIdle = throttled(updateMLStatusSnapshot, 2000);/*** Use CLIP to perform a natural language search over image embeddings.diff --git a/web/packages/new/photos/services/ml/worker-types.ts b/web/packages/new/photos/services/ml/worker-types.tsindex 72d6bce61b..446986b8ef 100644--- a/web/packages/new/photos/services/ml/worker-types.ts+++ b/web/packages/new/photos/services/ml/worker-types.ts@@ -8,11 +8,10 @@*/export interface MLWorkerDelegate {/**- * Called whenever a file is processed during indexing.- *- * It is called both when the indexing was successful or it failed.+ * Called whenever the worker processes a file during indexing (either+ * successfully or with errors), or when in goes into the "idle" state.*/- workerDidProcessFile: () => void;+ workerDidProcessFileOrIdle: () => void;}/**diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.tsindex 27dd602aef..0823a5806a 100644--- a/web/packages/new/photos/services/ml/worker.ts+++ b/web/packages/new/photos/services/ml/worker.ts@@ -233,6 +233,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();}/** Return the next batch of items to backfill (if any). */@@ -320,7 +321,7 @@ const indexNextBatch = async (await Promise.race(tasks);// Let the main thread now we're doing something.- delegate?.workerDidProcessFile();+ delegate?.workerDidProcessFileOrIdle();// Let us drain the microtask queue. This also gives a chance for other// interactive tasks like `clipMatches` to run.