refactor: replace service local node db with Room NodeDB

This commit is contained in:
andrekir 2024-09-13 00:19:21 -03:00
parent 84939a74d2
commit 39a18e6418
3 changed files with 31 additions and 92 deletions

View file

@ -70,13 +70,15 @@ 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) {
nodeInfoDao.apply {
clearNodeInfo()
clearMyNodeInfo()
setMyNodeInfo(mi) // set MyNodeInfo first
putAll(nodes)
}
clearNodeDB()
nodeInfoDao.setMyNodeInfo(mi) // set MyNodeInfo first
nodeInfoDao.putAll(nodes)
}
suspend fun deleteNode(num: Int) = withContext(Dispatchers.IO) {