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.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js
index 973729e..72c52ac 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/app.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/app.js
@@ -463,7 +463,7 @@ function Sidebar({ groups, presence, indexProgressPct, route, menuOpen, role, sh
href="#/create-group"><${Icon} name="plus" /> ${t('sidebar.create_group')}</a>
</div>
`}
- ${platform.photoSync.available && html`
+ ${PHONE_SYNC && html`
<div class="sidebar-section">
<div class="sidebar-heading">${t('sidebar.phone')}</div>
<a class="sidebar-item ${route === '/android-sync' ? 'active' : ''}"
@@ -715,8 +715,9 @@ const SearchPage = lazy(() => import('./search-page.js'), 'SearchPage',
// ── Lazy-loaded Android Sync page ────────────────────────────────────────────
//
-// The Android application's photo backup (docs/MESHBAY_DESIGN.md §9.12): no
-// browser or desktop ever fetches it.
+// The Android application's backups of its photos, contacts and messages
+// (docs/MESHBAY_DESIGN.md §9.12, §9.13): no browser or desktop ever fetches it.
+const PHONE_SYNC = platform.photoSync.available || platform.contactSync.available;
const AndroidSyncPage = lazy(() => import('./android-sync-page.js'), 'AndroidSyncPage',
html`<div class="page-content"><p class="page-message"><span class="spinner"></span></p></div>`);
@@ -942,6 +943,28 @@ function App() {
return () => { gone = true; if (stop) stop(); };
}, [syncAccount]);
+ // Contacts backup (§9.13), the same way.
+ useEffect(() => {
+ if (!syncAccount || !platform.contactSync.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;
+ },
+ });
+ stop = m.stopPhoneSync;
+ }).catch((e) => console.warn('[MeshBay] contacts backup did not load:', e.message));
+ return () => { gone = true; if (stop) stop(); };
+ }, [syncAccount]);
+
// Saving the queue is a shell-level action because the queue is: the player
// bar outlives every page, and the account it belongs to is here.
const [saveQueue, setSaveQueue] = useState(null);
@@ -1441,7 +1464,7 @@ function App() {
allowPublicGroups=${allowPublicGroups}
token=${user.token} onGroupsChanged=${reloadGroups}
onMarkRead=${markRead} onPurge=${purgeNotifications} />`;
- } else if (route === '/android-sync' && platform.photoSync.available) {
+ } else if (route === '/android-sync' && PHONE_SYNC) {
page = html`<${AndroidSyncPage} user=${user} groups=${groups} />`;
} else if (route === '/settings') {
page = html`<${SettingsPage} user=${user} theme=${theme}