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:
James Rich 2025-09-28 14:45:10 -05:00 committed by GitHub
parent cd010c4967
commit ac51c1b9f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.")
}
}