aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/app.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/app.js57
1 files changed, 34 insertions, 23 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js
index 41cc5f2..579d1dd 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,42 +942,40 @@ 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]);
- // Contacts and messages backup (§9.13), the same way.
+ // Files and WhatsApp backups (§9.13), the same way.
+ useEffect(() => {
+ if (!syncAccount || !(platform.driveSync.available || platform.whatsappSync.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.messageSync.available)) {
+ if (!syncAccount || !(platform.contactSync.available || platform.calendarSync.available
+ || platform.messageSync.available)) {
return undefined;
}
let stop = null;
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] contacts and messages backup did not load:', e.message));
+ }).catch((e) => console.warn('[MeshBay] phone backups did not load:', e.message));
return () => { gone = true; if (stop) stop(); };
}, [syncAccount]);