mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix(service): clear nodeDB when device address changes (#3232)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
cd010c4967
commit
ac51c1b9f6
1 changed files with 7 additions and 7 deletions
|
|
@ -432,7 +432,6 @@ class MeshService :
|
|||
//
|
||||
|
||||
private fun loadSettings() = serviceScope.handledLaunch {
|
||||
discardNodeDB() // Get rid of any old state
|
||||
myNodeInfo = nodeRepository.myNodeInfo.value
|
||||
nodeDBbyNodeNum.putAll(nodeRepository.getNodeDBbyNum().first())
|
||||
// Note: we do not haveNodeDB = true because that means we've got a valid db from a real
|
||||
|
|
@ -2000,19 +1999,20 @@ class MeshService :
|
|||
|
||||
fun clearDatabases() = serviceScope.handledLaunch {
|
||||
debug("Clearing nodeDB")
|
||||
discardNodeDB()
|
||||
nodeRepository.clearNodeDB()
|
||||
}
|
||||
|
||||
private fun updateLastAddress(deviceAddr: String?) {
|
||||
debug("setDeviceAddress: Passing through device change to radio service: ${deviceAddr.anonymize}")
|
||||
if (deviceAddr == meshPrefs.deviceAddress || deviceAddr == NO_DEVICE_SELECTED) {
|
||||
debug("SetDeviceAddress: Device address is the none or same, ignoring")
|
||||
return
|
||||
} else {
|
||||
debug("SetDeviceAddress: Device address changed from ${meshPrefs.deviceAddress} to $deviceAddr")
|
||||
val currentAddr = meshPrefs.deviceAddress
|
||||
debug("setDeviceAddress: received request to change to: ${deviceAddr.anonymize}")
|
||||
if (deviceAddr != currentAddr) {
|
||||
debug("SetDeviceAddress: Device address changed from ${currentAddr.anonymize} to ${deviceAddr.anonymize}")
|
||||
meshPrefs.deviceAddress = deviceAddr
|
||||
clearDatabases()
|
||||
clearNotifications()
|
||||
} else {
|
||||
debug("SetDeviceAddress: Device address is unchanged, ignoring.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue