mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(repository)!: improve api caching and error handling (#2680)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
9bde1f6357
commit
07cdbacf8f
4 changed files with 161 additions and 86 deletions
|
|
@ -264,7 +264,11 @@ constructor(
|
|||
val deviceHardware =
|
||||
actualNode.user.hwModel.number.let { deviceHardwareRepository.getDeviceHardwareByModel(it) }
|
||||
_state.update { state ->
|
||||
state.copy(node = actualNode, isLocal = destNum == ourNode, deviceHardware = deviceHardware)
|
||||
state.copy(
|
||||
node = actualNode,
|
||||
isLocal = destNum == ourNode,
|
||||
deviceHardware = deviceHardware.getOrNull(),
|
||||
)
|
||||
}
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
|
|
|
|||
|
|
@ -230,7 +230,9 @@ constructor(
|
|||
val deviceHardware: StateFlow<DeviceHardware?> =
|
||||
ourNodeInfo
|
||||
.mapNotNull { nodeInfo ->
|
||||
nodeInfo?.user?.hwModel?.let { deviceHardwareRepository.getDeviceHardwareByModel(it.number) }
|
||||
nodeInfo?.user?.hwModel?.let {
|
||||
deviceHardwareRepository.getDeviceHardwareByModel(it.number).getOrNull()
|
||||
}
|
||||
}
|
||||
.stateIn(scope = viewModelScope, started = SharingStarted.WhileSubscribed(5_000), initialValue = null)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue