Bugfix for klotter update: Home: rescan and mark nearby Klotter so new finds appear on location/setting changes
This commit is contained in:
@@ -329,6 +329,61 @@ fun KlottrAppShell(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Löser bugg som gjorde att Klotter-fynd inte dök upp: Klotter: skanna nära klotter och markera i FoundStore så Hem-fliken uppdateras
|
||||||
|
LaunchedEffect(showKlotter, locationTick) {
|
||||||
|
if (!showKlotter) return@LaunchedEffect
|
||||||
|
|
||||||
|
val gp = LocationServiceProvider.get().current(highAccuracy = false) ?: return@LaunchedEffect
|
||||||
|
lastKnownLat = gp.lat
|
||||||
|
lastKnownLon = gp.lon
|
||||||
|
|
||||||
|
// Hämta klotter inom standardradien (20 m)
|
||||||
|
val nearby = withContext(Dispatchers.IO) {
|
||||||
|
Geocache.getNearby(
|
||||||
|
lat = gp.lat,
|
||||||
|
lon = gp.lon,
|
||||||
|
radiusMeters = Config.DEFAULT_KLOTTER_RADIUS_M,
|
||||||
|
ttlMs = 0L
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Markera nya (ej tidigare kända) som "hittade"
|
||||||
|
val known = FoundStore.getAll()
|
||||||
|
.asSequence()
|
||||||
|
.filter { it.layer == LAYER_KLOTTER }
|
||||||
|
.map { it.id }
|
||||||
|
.toSet()
|
||||||
|
|
||||||
|
var anyNew = false
|
||||||
|
val now = Clock.System.now().toEpochMilliseconds()
|
||||||
|
|
||||||
|
for (n in nearby) {
|
||||||
|
val idStr = n.i.toString()
|
||||||
|
if (idStr !in known) {
|
||||||
|
FoundStore.markFound(
|
||||||
|
layer = LAYER_KLOTTER,
|
||||||
|
id = idStr,
|
||||||
|
label = n.t ?: "Klotter",
|
||||||
|
lat = n.a,
|
||||||
|
lon = n.o,
|
||||||
|
timeMillis = now
|
||||||
|
)
|
||||||
|
anyNew = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uppdatera away-flaggor (fetstil i listan blir korrekt)
|
||||||
|
FoundStore.updateAwayFlags(gp.lat, gp.lon)
|
||||||
|
|
||||||
|
if (anyNew) {
|
||||||
|
// Återställ ev. "tvinga tomt" och trigga omritning
|
||||||
|
forceEmptyFound = false
|
||||||
|
FoundEvents.notifyFoundUpdated()
|
||||||
|
refreshFound()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
CenterAlignedTopAppBar(
|
CenterAlignedTopAppBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user