From 1d07f76adaec1ce484300d5f73852e21cc33a974 Mon Sep 17 00:00:00 2001 From: wty2019wty <74123961+wty2019wty@users.noreply.github.com> Date: Sat, 19 Sep 2026 18:03:05 +0800 Subject: [PATCH] Fixed the AOS window filter so it follows the UTC setting (#252) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../core/data/repository/SatelliteRepo.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 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 464f870b..8dbc4c91 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 @@ -67,8 +69,9 @@ class SatelliteRepo( override suspend fun initRepository() = withContext(dispatcher) { combine( settingsRepo.selectedIds, - settingsRepo.stationPosition - ) { selectedIds, _ -> selectedIds } + settingsRepo.stationPosition, + settingsRepo.otherSettings.map { it.stateOfUtc }.distinctUntilChanged() + ) { selectedIds, _, _ -> selectedIds } .collect { selectedIds -> _satellites.update { localStorage.getEntriesWithIds(selectedIds) } val settings = settingsRepo.passesSettings.value @@ -176,7 +179,13 @@ class SatelliteRepo( aosEndMinute: Int, invertAosTimeWindow: Boolean ): Boolean { - val offsetMillis = TimeZone.getDefault().getOffset(aosTime).toLong() + // Must match the timezone used to display pass times (UTC toggle vs device local) + val tz = if (settingsRepo.otherSettings.value.stateOfUtc) { + TimeZone.getTimeZone("UTC") + } else { + TimeZone.getDefault() + } + val offsetMillis = tz.getOffset(aosTime).toLong() val localMillis = Math.floorMod(aosTime + offsetMillis, 24L * 60L * 60L * 1000L) val aosMinute = (localMillis / 60_000L).toInt() val inRange = if (aosStartMinute <= aosEndMinute) {