mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: improve NodeDB initialization
This commit is contained in:
parent
be741a9200
commit
e2c377107c
1 changed files with 6 additions and 5 deletions
|
|
@ -47,8 +47,12 @@ class NodeDB @Inject constructor(
|
|||
nodeInfoDao.getMyNodeInfo().onEach { _myNodeInfo.value = it }
|
||||
.launchIn(processLifecycle.coroutineScope)
|
||||
|
||||
nodeInfoDao.nodeDBbyNum().onEach { _nodeDBbyNum.value = it }
|
||||
.launchIn(processLifecycle.coroutineScope)
|
||||
nodeInfoDao.nodeDBbyNum().onEach {
|
||||
_nodeDBbyNum.value = it
|
||||
val ourNodeInfo = it.values.firstOrNull()
|
||||
_ourNodeInfo.value = ourNodeInfo
|
||||
_myId.value = ourNodeInfo?.user?.id
|
||||
}.launchIn(processLifecycle.coroutineScope)
|
||||
|
||||
nodeInfoDao.nodeDBbyID().onEach { _nodeDBbyID.value = it }
|
||||
.launchIn(processLifecycle.coroutineScope)
|
||||
|
|
@ -67,8 +71,5 @@ class NodeDB @Inject constructor(
|
|||
setMyNodeInfo(mi) // set MyNodeInfo first
|
||||
putAll(nodes)
|
||||
}
|
||||
val ourNodeInfo = nodes.find { it.num == mi.myNodeNum }
|
||||
_ourNodeInfo.value = ourNodeInfo
|
||||
_myId.value = ourNodeInfo?.user?.id
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue