From 751b05f271ef6ab2886be917b7e85b7839dcec8a Mon Sep 17 00:00:00 2001 From: archipelago Date: Fri, 31 Jul 2026 02:01:12 -0400 Subject: [PATCH] fix(02-review): WR-02 stop MeshMap geolocation watch on deactivate, resume on activate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit onDeactivated only tore down the resize listener/ResizeObserver, not the navigator.geolocation.watchPosition watch started by "Share Location" — leaving GPS polling running in the background (battery drain, active location indicator) for as long as the KeepAlive'd component survives, instead of only while the Mesh tab is visible like every other resource this phase added only-while-visible handling for in this file. onDeactivated now stops an active watch (tracked via a flag rather than losing the user's toggle state), and onActivated transparently resumes it on return to the tab. Co-Authored-By: Claude --- neode-ui/src/components/MeshMap.vue | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/neode-ui/src/components/MeshMap.vue b/neode-ui/src/components/MeshMap.vue index 2abc6943..9d1ecfed 100644 --- a/neode-ui/src/components/MeshMap.vue +++ b/neode-ui/src/components/MeshMap.vue @@ -421,12 +421,28 @@ function disarmMapVisibility() { // count as the first activation's arm, so onActivated only re-arms on a // genuine later reactivation, matching Mesh.vue's own meshFreshMount idiom. let mapMountFresh = true +// Set when a live geolocation watch is torn down by onDeactivated so +// onActivated can transparently resume it (WR-02) — the browser location +// watch must not keep firing (battery drain, background location indicator) +// while the Mesh tab is off screen, matching the only-while-visible pattern +// already applied to the resize listener/ResizeObserver in this file. +let wasSharingBeforeDeactivate = false onActivated(() => { if (mapMountFresh) { mapMountFresh = false; return } armMapVisibility() + if (wasSharingBeforeDeactivate) { + wasSharingBeforeDeactivate = false + startSharing() + } }) onMounted(() => armMapVisibility()) -onDeactivated(() => disarmMapVisibility()) +onDeactivated(() => { + disarmMapVisibility() + if (sharingLocation.value) { + wasSharingBeforeDeactivate = true + stopSharing() + } +}) onUnmounted(() => { disarmMapVisibility()