Fix add qr acting like replace instead of add (#3823)

Co-authored-by: Dane <dane@goneepic.com>
This commit is contained in:
Benjamin Faershtein 2025-11-26 06:25:55 -08:00 committed by GitHub
parent 13452edba6
commit 7fd1f19e18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -115,10 +115,20 @@ fun ScannedQrCodeDialog(
remember(channelSet) { mutableStateListOf(elements = Array(size = channelSet.settingsCount, init = { true })) }
val selectedChannelSet =
channelSet.copy {
val result = settings.filterIndexed { i, _ -> channelSelections.getOrNull(i) == true }
settings.clear()
settings.addAll(result)
if (shouldReplace) {
channelSet.copy {
val result = settings.filterIndexed { i, _ -> channelSelections.getOrNull(i) == true }
settings.clear()
settings.addAll(result)
}
} else {
channelSet.copy {
// When adding (not replacing), include all previous channels + selected new channels
val selectedNewChannels =
incoming.settingsList.filterIndexed { i, _ -> channelSelections.getOrNull(i) == true }
settings.clear()
settings.addAll(channels.settingsList + selectedNewChannels)
}
}
// Compute LoRa configuration changes when in replace mode