mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Add request metadata action to NodeDetail (#1896)
This commit is contained in:
parent
6fa329751d
commit
0057a6f2de
4 changed files with 52 additions and 12 deletions
|
|
@ -41,6 +41,7 @@ import com.geeksville.mesh.database.entity.MeshLog
|
|||
import com.geeksville.mesh.model.map.CustomTileSource
|
||||
import com.geeksville.mesh.navigation.Route
|
||||
import com.geeksville.mesh.repository.datastore.RadioConfigRepository
|
||||
import com.geeksville.mesh.service.ServiceAction
|
||||
import com.geeksville.mesh.ui.map.MAP_STYLE_ID
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
|
@ -66,6 +67,7 @@ import java.util.concurrent.TimeUnit
|
|||
import javax.inject.Inject
|
||||
|
||||
data class MetricsState(
|
||||
val isLocal: Boolean = false,
|
||||
val isManaged: Boolean = true,
|
||||
val isFahrenheit: Boolean = false,
|
||||
val displayUnits: DisplayUnits = DisplayUnits.METRIC,
|
||||
|
|
@ -214,6 +216,10 @@ class MetricsViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun onServiceAction(action: ServiceAction) = viewModelScope.launch {
|
||||
radioConfigRepository.onServiceAction(action)
|
||||
}
|
||||
|
||||
private val _state = MutableStateFlow(MetricsState.Empty)
|
||||
val state: StateFlow<MetricsState> = _state
|
||||
|
||||
|
|
@ -228,10 +234,10 @@ class MetricsViewModel @Inject constructor(
|
|||
init {
|
||||
destNum?.let {
|
||||
radioConfigRepository.nodeDBbyNum
|
||||
.mapLatest { nodes -> nodes[destNum] }
|
||||
.mapLatest { nodes -> nodes[destNum] to nodes.keys.firstOrNull() }
|
||||
.distinctUntilChanged()
|
||||
.onEach { node ->
|
||||
_state.update { state -> state.copy(node = node) }
|
||||
.onEach { (node, ourNode) ->
|
||||
_state.update { state -> state.copy(node = node, isLocal = destNum == ourNode) }
|
||||
node?.user?.hwModel?.let { hwModel ->
|
||||
val deviceHardware = getDeviceHardwareFromHardwareModel(hwModel)
|
||||
deviceHardware?.let {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue