mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix(widget): ensure local stats widget gets updates (#4722)
This commit is contained in:
parent
68b2b6d88e
commit
63984f0723
1 changed files with 5 additions and 5 deletions
|
|
@ -26,11 +26,13 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import org.meshtastic.core.common.util.nowMillis
|
||||
import org.meshtastic.core.model.ConnectionState
|
||||
import org.meshtastic.core.model.Node
|
||||
import org.meshtastic.core.model.util.onlineTimeThreshold
|
||||
import org.meshtastic.core.repository.AppWidgetUpdater
|
||||
import org.meshtastic.core.repository.NodeRepository
|
||||
import org.meshtastic.core.repository.ServiceRepository
|
||||
import org.meshtastic.proto.LocalStats
|
||||
|
|
@ -83,6 +85,7 @@ class LocalStatsWidgetStateProvider
|
|||
constructor(
|
||||
nodeRepository: NodeRepository,
|
||||
serviceRepository: ServiceRepository,
|
||||
appWidgetUpdater: AppWidgetUpdater,
|
||||
) {
|
||||
private val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
|
||||
|
||||
|
|
@ -105,11 +108,8 @@ constructor(
|
|||
mapToUiState(input.connectionState, input.totalNodes, input.onlineNodes, input.stats, input.localNode)
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.stateIn(
|
||||
scope = scope,
|
||||
started = SharingStarted.WhileSubscribed(5000),
|
||||
initialValue = LocalStatsWidgetUiState(),
|
||||
)
|
||||
.onEach { appWidgetUpdater.updateAll() }
|
||||
.stateIn(scope = scope, started = SharingStarted.Eagerly, initialValue = LocalStatsWidgetUiState())
|
||||
|
||||
private data class StateInput(
|
||||
val connectionState: ConnectionState,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue