fix(aprs): the notification showed the previous cycle's verdict

updateNotification was called from onReport but read lastState, which onState only sets
afterwards - so the persistent notification was rebuilt from the previous report's
outcome. It now derives the state from the report in hand.

This matters most where it is least visible: an alarm-driven report at 03:00 posts a
Toast nobody sees, leaving the notification as the only surface, and that surface was
showing a stale verdict.
This commit is contained in:
mckero committed 2026-08-25 16:10:53 +00:00
1 parent 321cd8f2fa
commit 271488a43e
1 file changed
+5
@@ -113,6 +113,11 @@ class AprsForegroundService : Service() {
onState = { lastState = it }, onState = { lastState = it },
onReport = { report -> onReport = { report ->
AprsStore.saveLastReport(this, report.ok, report.detail) AprsStore.saveLastReport(this, report.ok, report.detail)
// Derived from this report rather than read from lastState: onState fires AFTER
// onReport, so the notification was being rebuilt from the previous cycle's
// verdict. For an alarm-driven report at 03:00 the notification is the only
// surface that survives, and it was showing the wrong one.
lastState = if (report.ok) AprsState.Connected else AprsState.Error
updateNotification(cfg) updateNotification(cfg)
// Report result always surfaces: success = short Toast, failure = long Toast + reason // Report result always surfaces: success = short Toast, failure = long Toast + reason
// An unverified login needs its own message: the write succeeded, so a bare // An unverified login needs its own message: the write succeeded, so a bare