- Safe-delete unused declarations across app/ and shared/ - Optimize imports - KMP: align expect/actual for formatRelativeOrTime(ms: Long) and update callers - SettingsStore: remove duplicate wrapper functions causing overloads
36 lines
2.0 KiB
Kotlin
36 lines
2.0 KiB
Kotlin
package app.klottr.nearby //Regler för “Närliggande” (logik i commonMain)
|
|
|
|
import app.klottr.net.DigitaltMuseumItem //För att kunna slå upp DM-poster
|
|
import app.klottr.net.FornsokItem //För att kunna slå upp Fornsök-poster
|
|
import app.klottr.util.FoundStore //Lagerkonstanter
|
|
|
|
//Centraliserad regel: vilka entries är klickbara?
|
|
fun isClickable( //
|
|
entry: NearbyEntryShared, //Raden vi bedömer
|
|
dm: List<DigitaltMuseumItem>, //DM-listan (för id-uppslag)
|
|
forn: List<FornsokItem> //Fornsök-listan (för id-uppslag)
|
|
): Boolean = when (entry.layer) { //
|
|
FoundStore.LAYER_WIKI, //Wiki: klickbar om id finns
|
|
FoundStore.LAYER_KLOTTER -> entry.id != null //
|
|
FoundStore.LAYER_DM -> dm.any { it.id == entry.id } //Klickbar om vi hittar DM-objektet
|
|
FoundStore.LAYER_FORNSOK -> forn.any { it.id == entry.id } //Klickbar om vi hittar Fornsök-objektet
|
|
else -> false //
|
|
}
|
|
|
|
//Markera nya fynd i FoundStore baserat på delade entries (plattformneutral hjälpare)
|
|
fun markNewFinds( //
|
|
ctx: Any?, //Context-parameter hålls som Any? i KMP
|
|
entries: List<NearbyEntryShared>, //Delade “Närliggande”-rader
|
|
nowMillis: Long, //Tidpunkt för markering
|
|
onMarked: () -> Unit //Callback om något faktiskt markerats nytt
|
|
) {
|
|
for (e in entries) { //
|
|
val id = e.id //Lokal kopia för säkra null-kontroller mellan moduler
|
|
if (e.distanceM <= e.insideRadiusM && id != null) { //Samma villkor som i appen
|
|
if (FoundStore.markFound(e.layer, id, e.label, e.lat, e.lon, nowMillis)) { //
|
|
onMarked() //Signalera att något nytt markerades
|
|
}
|
|
}
|
|
}
|
|
}
|