diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/platform.js | 25 |
1 files changed, 25 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 c70b03a..c5ae9ee 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js @@ -230,6 +230,31 @@ export const push = { }, }; +/** + * Backing up this phone's photos to a group (docs/MESHBAY_DESIGN.md §9.12). + * Only the Android application has a camera roll to read; `available` is false + * in a browser and on a desktop. See photo-sync.js. + */ +export const photoSync = { + available: Boolean(bridge && bridge.photoSync), + status() { return bridge.photoSync.status(); }, + permit() { return bridge.photoSync.permit(); }, + albums() { return bridge.photoSync.albums(); }, + configure(settings) { return bridge.photoSync.configure(settings); }, + estimate(settings) { return bridge.photoSync.estimate(settings); }, + plan() { return bridge.photoSync.plan(); }, + sent(token, dir, name) { return bridge.photoSync.sent(token, dir, name); }, + completed() { return bridge.photoSync.completed(); }, + failed(code, text) { return bridge.photoSync.failed(code, text); }, + keepAlive(on, text) { return bridge.photoSync.keepAlive(on, text); }, + /** The bytes of a photo the last plan issued, as a File named for the node. */ + async file(token, name) { + const r = await fetch(`/photosync/${encodeURIComponent(token)}`, { cache: 'no-store' }); + if (!r.ok) throw new Error('This photo is no longer on the phone'); + return new File([await r.blob()], name); + }, +}; + /** Pick a directory to add as a group root. Returns { path, name } or null. */ export const rootPicker = { available: Boolean(bridge && bridge.rootPicker), |