From 135bcf8b8a9798a70932f82066d307a1f362fa91 Mon Sep 17 00:00:00 2001 From: andrekir Date: Sat, 13 May 2023 18:35:16 -0300 Subject: [PATCH] fix: revert unintended changes from a3164955459a3d3bf914e2f40636c9a91d882662 --- .../mesh/ui/DeviceSettingsFragment.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/DeviceSettingsFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/DeviceSettingsFragment.kt index 19a6fcd6..5c339e30 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/DeviceSettingsFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/DeviceSettingsFragment.kt @@ -70,6 +70,8 @@ import com.geeksville.mesh.NodeInfo import com.geeksville.mesh.Portnums import com.geeksville.mesh.R import com.geeksville.mesh.android.Logging +import com.geeksville.mesh.channel +import com.geeksville.mesh.channelSettings import com.geeksville.mesh.config import com.geeksville.mesh.deviceProfile import com.geeksville.mesh.model.UIViewModel @@ -393,7 +395,20 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) { focusManager = focusManager, onSaveClicked = { channelListInput -> focusManager.clearFocus() - viewModel.updateChannels(destNum, channelList, channelListInput) + (0 until channelList.size.coerceAtLeast(channelListInput.size)).map { i -> + channel { + role = when (i) { + 0 -> ChannelProtos.Channel.Role.PRIMARY + in 1 until channelListInput.size -> ChannelProtos.Channel.Role.SECONDARY + else -> ChannelProtos.Channel.Role.DISABLED + } + index = i + settings = channelListInput.getOrNull(i) ?: channelSettings { } + } + }.forEach { newChannel -> + if (newChannel.settings != channelList.getOrNull(newChannel.index)) + viewModel.setRemoteChannel(destNum, newChannel) + } channelList.clear() channelList.addAll(channelListInput) }