findfamily: clear stale history position, panel scrubber on wide (#818)
- Commit
f642203758b20f86ae0e9922c4770a8eb190aa8f- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-14 23:54 UTC (1 month ago)
- Parents
aaa626d
Diff
findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.ktindex cde981d739..57b8028445 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPage.kt@@ -78,6 +78,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue+import androidx.compose.runtime.key import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember@@ -280,10 +281,15 @@ fun MainPage( actions = mainActions, historyScrubber = { if (historyMode) {- HistoryScrubber(- backStack,- ffViewModel- ) { ffViewModel.mapState.setHistoricalPosition(it) }+ // Scoped to the person: a deep link can swap the selection while history+ // mode stays on, and the scrubber must restart from now for the new person+ // rather than inherit the previous one's instant.+ key(selectedUserId) {+ HistoryScrubber(+ backStack,+ ffViewModel+ ) { ffViewModel.mapState.setHistoricalPosition(it) }+ } } }, map = {
findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageCards.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageCards.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageCards.ktindex aa262c8fbc..4c84205f43 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageCards.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageCards.kt@@ -88,6 +88,10 @@ fun BoxScope.HistoryScrubber( if (locs.isNotEmpty()) { val closest = locs.minBy { (it.timestamp - state.instant).absoluteValue } setHistoricalPosition(closest.coord.toGeoPoint())+ } else {+ // Nobody to show a pin for: drop any position left over from whoever was+ // viewed before, so their track never masquerades as this person's.+ setHistoricalPosition(null) } } }
findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageContent.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageContent.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageContent.ktindex 190a4933bf..55d484c5a2 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageContent.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/ui/MainPageContent.kt@@ -2,6 +2,8 @@ package com.vayunmathur.findfamily.ui import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height@@ -115,11 +117,20 @@ fun MainPageContent( if (expanded) { FindFamilyWideLayout( map = { map() },- panel = {+ panel = { modifier -> if (state.nothingSelected) { FamilyListSheet(state.familyList, familyActions)- } else if (!state.historyMode && state.selectedUserId != null) {- state.person?.let { PersonDetailSheet(it, personActions) }+ } else if (state.selectedUserId != null) {+ Column(modifier) {+ state.person?.let { PersonDetailSheet(it, personActions) }+ if (state.historyMode) {+ // The phone layout floats the scrubber over the map; the side+ // panel hosts it instead, under the person's card, so history+ // is usable here rather than an empty panel (GitHub #818).+ Spacer(Modifier.weight(1f))+ Box(Modifier.fillMaxWidth()) { historyScrubber() }+ }+ } } }, )
findfamily/src/main/java/com/vayunmathur/findfamily/util/MapPageState.kt
diff --git a/findfamily/src/main/java/com/vayunmathur/findfamily/util/MapPageState.kt b/findfamily/src/main/java/com/vayunmathur/findfamily/util/MapPageState.ktindex a37f271813..84209e3499 100644--- a/findfamily/src/main/java/com/vayunmathur/findfamily/util/MapPageState.kt+++ b/findfamily/src/main/java/com/vayunmathur/findfamily/util/MapPageState.kt@@ -47,9 +47,19 @@ class MapPageState( private val _waypointCoord = MutableStateFlow(Coord(0.0, 0.0)) val waypointCoord: StateFlow<Coord> = _waypointCoord.asStateFlow() - fun setSelectedUserId(id: Long?) { _selectedUserId.value = id }+ fun setSelectedUserId(id: Long?) {+ _selectedUserId.value = id+ // A new person means no historical pin yet: never show whoever was viewed+ // before as this person's position (GitHub #818 follow-up).+ _historicalPosition.value = null+ } fun setSelectedWaypointId(id: Long?) { _selectedWaypointId.value = id }- fun setShowingPresent(value: Boolean) { _isShowingPresent.value = value }+ fun setShowingPresent(value: Boolean) {+ _isShowingPresent.value = value+ // Leaving history drops the historical pin with it, so it cannot linger as a+ // ghost marker or a stale camera target once live tracking resumes.+ if (value) _historicalPosition.value = null+ } fun setHistoricalPosition(position: GeoPoint?) { _historicalPosition.value = position } fun setWaypointName(name: String) { _waypointName.value = name } fun setWaypointRange(range: String) { _waypointRange.value = range }@@ -59,11 +69,15 @@ class MapPageState( _selectedUserId.value = userId _selectedWaypointId.value = null _isShowingPresent.value = true+ // Same reason as setSelectedUserId: the newly selected person starts with no+ // historical pin of their own.+ _historicalPosition.value = null } fun clearSelection() { _selectedUserId.value = null _selectedWaypointId.value = null+ _historicalPosition.value = null } /**@@ -74,6 +88,9 @@ class MapPageState( fun applyInitialSelection(initialUserId: Long?, initialWaypointId: Long?) { _selectedUserId.value = initialUserId _selectedWaypointId.value = initialWaypointId+ // A deep link can swap the person while history mode stays on, so the previous+ // person's pin must not survive the switch.+ _historicalPosition.value = null } /** Begin creating a brand-new waypoint with sensible defaults. */