From 6a6399b606d3bc811961cdb6cd1fa6097e6b762c Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Mon, 14 Sep 2026 18:54:22 +0800 Subject: [PATCH] fix(passes): recalculate passes when the UTC toggle changes Port of upstream PR #252 (wty2019wty): combine otherSettings.stateOfUtc into initRepository so an existing AOS time window is reapplied in the newly selected timezone right after toggling UTC, instead of waiting for the next selection/position change. --- .../look4sat/core/data/repository/SatelliteRepo.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt b/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt index b9a27927..43270d13 100644 --- a/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt +++ b/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt @@ -35,6 +35,8 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.update import kotlinx.coroutines.withContext import java.util.TimeZone @@ -66,8 +68,11 @@ class SatelliteRepo( override suspend fun initRepository() = withContext(dispatcher) { combine( settingsRepo.selectedIds, - settingsRepo.stationPosition - ) { selectedIds, _ -> selectedIds } + settingsRepo.stationPosition, + // Recalculate passes when the UTC display toggle changes, so an existing + // AOS time window is reapplied in the newly selected timezone. + settingsRepo.otherSettings.map { it.stateOfUtc }.distinctUntilChanged() + ) { selectedIds, _, _ -> selectedIds } .collect { selectedIds -> _satellites.update { localStorage.getEntriesWithIds(selectedIds) } val settings = settingsRepo.passesSettings.value