- Track removed events via removedSinceLoad set in Logbook to prevent merge from re-adding deliberately deleted or cancelled events - Deduplicate finalized timer events (same type + similar start time) to prevent duplicates when both devices stop the same timer - Detect timer cancellation from other device: dismiss local timer dialog when ongoing event disappears from logbook after sync - Fix thread safety: take snapshot of events before background merge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
552 B
Kotlin
24 lines
552 B
Kotlin
package it.danieleverducci.lunatracker.entities
|
|
|
|
class Logbook(val name: String) {
|
|
companion object {
|
|
const val MAX_SAFE_LOGBOOK_SIZE = 30000
|
|
}
|
|
val logs = ArrayList<LunaEvent>()
|
|
val removedSinceLoad = mutableSetOf<String>()
|
|
|
|
fun isTooBig(): Boolean {
|
|
return logs.size > MAX_SAFE_LOGBOOK_SIZE
|
|
}
|
|
|
|
/**
|
|
* Halves the logbook to avoid the file being too big
|
|
*/
|
|
fun trim() {
|
|
logs.subList(MAX_SAFE_LOGBOOK_SIZE/2, logs.size).clear()
|
|
}
|
|
|
|
fun sort() {
|
|
logs.sortDescending()
|
|
}
|
|
} |