diff --git a/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt b/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt index a858d1ba3..84c5f56ab 100644 --- a/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt +++ b/core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt @@ -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