diff --git a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/navigation/SettingsNavUtils.kt b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/navigation/SettingsNavUtils.kt deleted file mode 100644 index 93e5763ef..000000000 --- a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/navigation/SettingsNavUtils.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2026 Meshtastic LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.meshtastic.feature.settings.navigation - -import org.meshtastic.core.navigation.Route - -fun getNavRouteFrom(routeName: String): Route? = - ConfigRoute.entries.find { it.name == routeName }?.route ?: ModuleRoute.entries.find { it.name == routeName }?.route diff --git a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt index 348a895a9..0a76ba757 100644 --- a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt +++ b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/RadioConfigViewModel.kt @@ -89,7 +89,7 @@ import org.meshtastic.core.model.ResponseState data class RadioConfigState( val isLocal: Boolean = false, val connected: Boolean = false, - val route: String = "", + val route: Enum<*>? = null, val metadata: DeviceMetadata? = null, val userConfig: User = User(), val channelList: List = emptyList(), @@ -385,7 +385,7 @@ open class RadioConfigViewModel( .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), ResponseState.Empty) override val pendingRouteName: StateFlow = - _radioConfigState.map { it.route } + _radioConfigState.map { it.route?.name.orEmpty() } .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), "") override fun requestConfigLoad(routeName: String) { @@ -404,7 +404,7 @@ open class RadioConfigViewModel( fun setResponseStateLoading(route: Enum<*>) { val destNum = destNumFlow.value ?: destNode.value?.num ?: return - _radioConfigState.update { it.copy(route = route.name, responseState = ResponseState.Loading()) } + _radioConfigState.update { it.copy(route = route, responseState = ResponseState.Loading()) } loadJob?.cancel() loadJob = viewModelScope.launch { diff --git a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/channel/ChannelScreen.kt b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/channel/ChannelScreen.kt index b99de7248..243b80348 100644 --- a/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/channel/ChannelScreen.kt +++ b/feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/radio/channel/ChannelScreen.kt @@ -93,7 +93,7 @@ import org.meshtastic.core.ui.util.rememberQrCodePainter import org.meshtastic.core.ui.util.rememberShowToastResource import org.meshtastic.feature.settings.channel.ChannelViewModel import org.meshtastic.feature.settings.navigation.ConfigRoute -import org.meshtastic.feature.settings.navigation.getNavRouteFrom +import org.meshtastic.feature.settings.navigation.ModuleRoute import org.meshtastic.feature.settings.radio.RadioConfigViewModel import org.meshtastic.core.ui.component.PacketResponseStateDialog import org.meshtastic.proto.ChannelSet @@ -140,10 +140,12 @@ fun ChannelScreen( radioConfigViewModel.clearPacketResponse() }, onComplete = { - getNavRouteFrom(radioConfigState.route)?.let { route -> + val navRoute = (radioConfigState.route as? ConfigRoute)?.route + ?: (radioConfigState.route as? ModuleRoute)?.route + if (navRoute != null) { isWaiting = false radioConfigViewModel.clearPacketResponse() - onNavigate(route) + onNavigate(navRoute) } }, )