refactor: decouple NavGraph from ViewModel and NodeEntity

This commit is contained in:
andrekir 2024-11-30 07:50:15 -03:00
parent 6678df78b0
commit 716a3f535f
5 changed files with 69 additions and 43 deletions

View file

@ -68,6 +68,7 @@ import javax.inject.Inject
* Data class that represents the current RadioConfig state.
*/
data class RadioConfigState(
val isLocal: Boolean = false,
val connected: Boolean = false,
val route: String = "",
val metadata: MeshProtos.DeviceMetadata = MeshProtos.DeviceMetadata.getDefaultInstance(),
@ -121,6 +122,10 @@ class RadioConfigViewModel @Inject constructor(
}
}.launchIn(viewModelScope)
radioConfigRepository.myNodeInfo.onEach { ni ->
_radioConfigState.update { it.copy(isLocal = destNum == null || destNum == ni?.myNodeNum) }
}.launchIn(viewModelScope)
debug("RadioConfigViewModel created")
}