fix: revert unintended changes from a316495545

pull/634/head
andrekir 2023-05-13 18:35:16 -03:00
rodzic 0c78bc4e49
commit 135bcf8b8a
1 zmienionych plików z 16 dodań i 1 usunięć

Wyświetl plik

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