From a589febd8d4a6cdcf16a88c9f7c921a759a81e71 Mon Sep 17 00:00:00 2001 From: andrekir Date: Sat, 19 Aug 2023 07:48:11 -0300 Subject: [PATCH] refactor: simplify `ourNodeInfo` updates --- app/src/main/java/com/geeksville/mesh/model/UIState.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/model/UIState.kt b/app/src/main/java/com/geeksville/mesh/model/UIState.kt index 9278168d1..6bc72e062 100644 --- a/app/src/main/java/com/geeksville/mesh/model/UIState.kt +++ b/app/src/main/java/com/geeksville/mesh/model/UIState.kt @@ -149,9 +149,6 @@ class UIViewModel @Inject constructor( radioConfigRepository.channelSetFlow.onEach { channelSet -> _channels.value = ChannelSet(channelSet) }.launchIn(viewModelScope) - combine(nodeDB.nodes.asFlow(), nodeDB.myId.asFlow()) { nodes, id -> nodes[id] }.onEach { - _ourNodeInfo.value = it - }.launchIn(viewModelScope) viewModelScope.launch { combine(meshLogRepository.getAllLogs(9), requestId) { list, id -> @@ -433,7 +430,9 @@ class UIViewModel @Inject constructor( try { // Pull down our real node ID - This must be done AFTER reading the nodedb because we need the DB to find our nodeinof object - nodeDB.setMyId(service.myId) + val myId = service.myId + nodeDB.setMyId(myId) + _ourNodeInfo.value = nodes[myId] } catch (ex: Exception) { warn("Ignoring failure to get myId, service is probably just uninited... ${ex.message}") }