From a0793dd37030f7213ecb07a018b11e6a8adf9238 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 10 Oct 2026 12:56:26 +0200 Subject: feat(android): back the phone's contacts up to a group of one's own A Contacts backup section on the Android Sync page sends a dated .vcf into /-contacts once a day when the address book changed, only to a group the account is alone in, checked again at every run. Co-Authored-By: Claude Opus 5.5 --- .../meshbay-hub/src/meshbay_hub/static/platform.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js') 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), -- cgit v1.2.3