aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js b/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
index a9d4517..9a45cf8 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
@@ -25,6 +25,8 @@ const RETRY_MS = 15 * 60 * 1000;
// A slot the node keeps queued this long means it is busy with others; the
// backup can wait for tomorrow's run, they cannot.
const LEASE_WAIT_MS = 10 * 60 * 1000;
+// The notification's progress line is updated at most this often.
+const NOTIFY_MS = 1000;
// Refusals that will hold at the next run too. Said once (a notification, from
// the phone) and retried a day later, never at every opening.
@@ -216,11 +218,18 @@ export function createBackup({
for (const r of index.roots || []) dirs.add(r.name);
let done = 0;
- const report = () => {
+ // The page follows every file; the notification at most once a second,
+ // which is all Android shows anyway: files already on the node go by
+ // faster than that, and a burst of updates is dropped by the system.
+ let reported = 0;
+ const report = async () => {
setState({ phase: 'sending', done, total: items.length });
- return t(progress, { done, total: items.length });
+ const now = Date.now();
+ if (done && done < items.length && now - reported < NOTIFY_MS) return;
+ reported = now;
+ await sync.keepAlive(true, t(progress, { done, total: items.length }));
};
- await sync.keepAlive(true, report());
+ await report();
for (const item of items) {
// Off Wi-Fi mid-run: stop after the file in flight. The node keeps the
@@ -244,7 +253,7 @@ export function createBackup({
}
}
done += 1;
- await sync.keepAlive(true, report());
+ await report();
}
if (!await sendManifest(transport, dest, dirs)) return;
await sync.completed();