refactor(MeshService): remove discardNodeDB and simplify logic

This commit is contained in:
andrekir 2024-09-13 18:38:04 -03:00
parent 1252b67fce
commit a98d3899e6
3 changed files with 3 additions and 17 deletions

View file

@ -70,14 +70,10 @@ class NodeDB @Inject constructor(
nodeInfoDao.upsert(node)
}
suspend fun clearNodeDB() = withContext(Dispatchers.IO) {
nodeInfoDao.clearNodeInfo()
nodeInfoDao.clearMyNodeInfo()
}
suspend fun installNodeDB(mi: MyNodeInfo, nodes: List<NodeInfo>) = withContext(Dispatchers.IO) {
clearNodeDB()
nodeInfoDao.clearMyNodeInfo()
nodeInfoDao.setMyNodeInfo(mi) // set MyNodeInfo first
nodeInfoDao.clearNodeInfo()
nodeInfoDao.putAll(nodes)
}