diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/app.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/app.js | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js index 031e276..d8818d0 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/app.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/app.js @@ -919,6 +919,19 @@ function App() { pullOnce(user.userId).catch(() => {}); }, [user, groups.length]); + // What every phone backup runs with: the live user and bundle key, read + // when a run starts, never ones captured here. + const backupContext = () => ({ + hub: HUB, + hubFetch, + getUser: () => userRef.current, + getBundleKey: async () => { + const key = session.bundleKey || await _loadBundleKey(); + if (key) session.bundleKey = key; + return key; + }, + }); + // Photo backup (docs/MESHBAY_DESIGN.md §9.12), on the Android application // only: loaded and started once signed in, stopped on sign-out. A run reads // the live user and bundle key when it starts, never ones captured here. @@ -929,21 +942,25 @@ function App() { let gone = false; import('./photo-sync.js').then((m) => { if (gone) return; - m.startPhotoSync({ - hub: HUB, - hubFetch, - getUser: () => userRef.current, - getBundleKey: async () => { - const key = session.bundleKey || await _loadBundleKey(); - if (key) session.bundleKey = key; - return key; - }, - }); + m.startPhotoSync(backupContext()); stop = m.stopPhotoSync; }).catch((e) => console.warn('[MeshBay] photo backup did not load:', e.message)); return () => { gone = true; if (stop) stop(); }; }, [syncAccount]); + // Files backup (§9.13), the same way. + useEffect(() => { + if (!syncAccount || !platform.driveSync.available) return undefined; + let stop = null; + let gone = false; + import('./drive-sync.js').then((m) => { + if (gone) return; + m.startDriveSync(backupContext()); + stop = m.stopDriveSync; + }).catch((e) => console.warn('[MeshBay] files backup did not load:', e.message)); + return () => { gone = true; if (stop) stop(); }; + }, [syncAccount]); + // Contacts, calendar and messages backup (§9.13), the same way. useEffect(() => { if (!syncAccount || !(platform.contactSync.available || platform.calendarSync.available @@ -954,16 +971,7 @@ function App() { let gone = false; import('./phone-sync.js').then((m) => { if (gone) return; - m.startPhoneSync({ - hub: HUB, - hubFetch, - getUser: () => userRef.current, - getBundleKey: async () => { - const key = session.bundleKey || await _loadBundleKey(); - if (key) session.bundleKey = key; - return key; - }, - }); + m.startPhoneSync(backupContext()); stop = m.stopPhoneSync; }).catch((e) => console.warn('[MeshBay] phone backups did not load:', e.message)); return () => { gone = true; if (stop) stop(); }; |