diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/AlwaysOnNotificationServiceManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/AlwaysOnNotificationServiceManager.kt index d2bcd9d240..30b3add1dc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/AlwaysOnNotificationServiceManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/AlwaysOnNotificationServiceManager.kt @@ -149,12 +149,17 @@ class AlwaysOnNotificationServiceManager( // The service layers are a background concern, so they stay tied to // the master switch and to somebody having opted in. A foreground-only // account must not start a foreground service that outlives the screen. - if (masterEnabled && participating.isNotEmpty()) { - wasEnabled = true - enableServiceLayers() - } else if (wasEnabled) { - disableServiceLayers() - wasEnabled = false + // + // Edge-triggered, deliberately. This flow re-emits whenever the account + // map changes identity or the app crosses foreground — far more often + // than the old boolean did — and ServiceWatchdogManager.schedule() + // replaces its alarm with one starting `now + 5min`. Calling it on every + // emission pushed the watchdog's first fire past every screen-on, so the + // layer that exists to restart a dead service would never have run. + val shouldRun = masterEnabled && participating.isNotEmpty() + if (shouldRun != wasEnabled) { + if (shouldRun) enableServiceLayers() else disableServiceLayers() + wasEnabled = shouldRun } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/subscriptions/ActiveSubscriptionsViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/subscriptions/ActiveSubscriptionsViewModel.kt index 2a34e09b2d..a5db379f0b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/subscriptions/ActiveSubscriptionsViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/subscriptions/ActiveSubscriptionsViewModel.kt @@ -136,10 +136,7 @@ data class ActiveSubscriptionsState( * overstate every card, which is the mistake the per-entity rows already taught once. */ val attributedFilters: Int = 0, -) { - /** The largest purpose, so every card can draw its share against a common scale. */ - val busiestPurposeFilters: Int = accounts.flatMap { it.purposes }.maxOfOrNull { it.filterCount } ?: 0 -} +) class ActiveSubscriptionsViewModel : ViewModel() { private val _state = MutableStateFlow(ActiveSubscriptionsState())