kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
refactor(MeshService): remove `discardNodeDB` and simplify logic
rodzic
1252b67fce
commit
a98d3899e6
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ class RadioConfigRepository @Inject constructor(
|
|||
val nodeDBbyNum: StateFlow<Map<Int, NodeInfo>> get() = nodeDB.nodeDBbyNum
|
||||
|
||||
suspend fun upsert(node: NodeInfo) = nodeDB.upsert(node)
|
||||
suspend fun clearNodeDB() = nodeDB.clearNodeDB()
|
||||
suspend fun installNodeDB(mi: MyNodeInfo, nodes: List<NodeInfo>) {
|
||||
nodeDB.installNodeDB(mi, nodes)
|
||||
}
|
||||
|
|
|
@ -323,15 +323,6 @@ class MeshService : Service(), Logging {
|
|||
/// BEGINNING OF MODEL - FIXME, move elsewhere
|
||||
///
|
||||
|
||||
/**
|
||||
* discard entire node db - used before downloading a new db from the device
|
||||
*/
|
||||
private fun discardNodeDB() = serviceScope.handledLaunch {
|
||||
debug("Discarding NodeDB")
|
||||
radioConfigRepository.clearNodeDB()
|
||||
haveNodeDB = false
|
||||
}
|
||||
|
||||
val myNodeInfo: MyNodeInfo? get() = radioConfigRepository.myNodeInfo.value
|
||||
|
||||
private val configTotal by lazy { ConfigProtos.Config.getDescriptor().fields.size }
|
||||
|
@ -1591,7 +1582,7 @@ class MeshService : Service(), Logging {
|
|||
|
||||
val res = radioInterfaceService.setDeviceAddress(deviceAddr)
|
||||
if (res) {
|
||||
discardNodeDB()
|
||||
haveNodeDB = false
|
||||
} else {
|
||||
serviceBroadcasts.broadcastConnection()
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue