aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/platform.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/platform.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
index c5ae9ee..1715d5f 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
@@ -255,6 +255,33 @@ export const photoSync = {
},
};
+/**
+ * Backing up one kind of this phone's data (the contacts) to a group of
+ * which the person is the only member (docs/MESHBAY_DESIGN.md §9.13). Android
+ * only, like `photoSync`. See phone-sync.js.
+ */
+function docSync(name) {
+ const b = bridge && bridge[name];
+ return {
+ available: Boolean(b),
+ status() { return b.status(); },
+ permit() { return b.permit(); },
+ configure(settings) { return b.configure(settings); },
+ plan() { return b.plan(); },
+ sent(token, dir, n) { return b.sent(token, dir, n); },
+ completed() { return b.completed(); },
+ failed(code, text) { return b.failed(code, text); },
+ /** The file the last plan wrote, as a File named for the node. */
+ async file(token, fileName) {
+ const r = await fetch(`/phonesync/${encodeURIComponent(token)}`, { cache: 'no-store' });
+ if (!r.ok) throw new Error('This file is no longer on the phone');
+ return new File([await r.blob()], fileName);
+ },
+ };
+}
+
+export const contactSync = docSync('contactSync');
+
/** Pick a directory to add as a group root. Returns { path, name } or null. */
export const rootPicker = {
available: Boolean(bridge && bridge.rootPicker),