fix(config): show error when radio disconnects before receiving confirmation

This commit is contained in:
andrekir
2024-10-19 13:29:39 -03:00
parent abcc2e89ec
commit 8af78bc2eb
2 changed files with 10 additions and 1 deletions

View File

@@ -100,6 +100,12 @@ class RadioConfigViewModel @Inject constructor(
radioConfigRepository.meshPacketFlow.onEach(::processPacketResponse)
.launchIn(viewModelScope)
combine(connectionState, radioConfigState) { connState, configState ->
if (connState.isDisconnected() && configState.responseState.isWaiting()) {
setResponseStateError(app.getString(R.string.disconnected))
}
}.launchIn(viewModelScope)
debug("RadioConfigViewModel created")
}

View File

@@ -135,7 +135,10 @@ class MeshService : Service(), Logging {
enum class ConnectionState {
DISCONNECTED,
CONNECTED,
DEVICE_SLEEP // device is in LS sleep state, it will reconnected to us over bluetooth once it has data
DEVICE_SLEEP, // device is in LS sleep state, it will reconnected to us over bluetooth once it has data
;
fun isDisconnected() = this == DISCONNECTED
}
private var previousSummary: String? = null