diff --git a/src/ui-desktop/components/SettingsModal.jsx b/src/ui-desktop/components/SettingsModal.jsx index d45352e..2403eaa 100644 --- a/src/ui-desktop/components/SettingsModal.jsx +++ b/src/ui-desktop/components/SettingsModal.jsx @@ -43,6 +43,10 @@ export function SettingsModal ({ tokens, profile, updateProfile, db, sync, event // auto-started at login. Default off; the truth lives in the OS login-item, // read here on open via db.getLaunchAtLogin (electron main intercept). const [launchAtLogin, setLaunchAtLogin] = useState(false) + // TODO #134 - null until loaded; `configured: false` means this build has no + // relay wired at all, in which case the section stays hidden rather than + // offering a switch that controls nothing. + const [relayStatus, setRelayStatus] = useState(null) useEffect(() => { function onKey (e) { if (e.key === 'Escape') onClose() } @@ -56,6 +60,25 @@ export function SettingsModal ({ tokens, profile, updateProfile, db, sync, event return () => { alive = false } }, [db]) + useEffect(() => { + let alive = true + db?.getRelayStatus?.().then(s => { if (alive) setRelayStatus(s ?? null) }).catch(() => {}) + return () => { alive = false } + }, [db]) + + // Optimistic like the toggle above, and re-read afterwards so the counters + // below reflect what the worklet actually did rather than what we asked for. + async function handleUseRelayChange (next) { + setRelayStatus(prev => prev ? { ...prev, useRelay: next } : prev) + try { + await db?.setUseRelay?.(next) + const fresh = await db?.getRelayStatus?.() + if (fresh) setRelayStatus(fresh) + } catch (e) { + setRelayStatus(prev => prev ? { ...prev, useRelay: !next } : prev) + } + } + async function handleLaunchAtLoginChange (next) { setLaunchAtLogin(next) // optimistic try { @@ -295,6 +318,40 @@ export function SettingsModal ({ tokens, profile, updateProfile, db, sync, event + {/* Connection — the off-LAN relay backstop (TODO #130 engine, #134 control). + Wording deliberately mirrors mobile's: same feature, same promise. */} + {relayStatus?.configured && ( +