diff --git a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt index 7072d9d58..8af5bc710 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt @@ -49,6 +49,7 @@ import androidx.compose.material.icons.twotone.Check import androidx.compose.material.icons.twotone.Close import androidx.compose.material.icons.twotone.ContentCopy import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf @@ -321,6 +322,11 @@ fun ChannelScreen( channelSelections = channelSelections, onClick = { showChannelEditor = true } ) + EditChannelUrl( + enabled = enabled, + channelUrl = selectedChannelSet.getChannelUrl(), + onConfirm = viewModel::requestChannelUrl + ) } } else { dragDropItemsIndexed( @@ -354,14 +360,6 @@ fun ChannelScreen( } } - item { - EditChannelUrl( - enabled = enabled, - channelUrl = selectedChannelSet.getChannelUrl(), - onConfirm = viewModel::requestChannelUrl - ) - } - item { DropDownPreference(title = stringResource(id = R.string.channel_options), enabled = enabled, @@ -419,6 +417,13 @@ private fun EditChannelUrl( var valueState by remember(channelUrl) { mutableStateOf(channelUrl) } var isError by remember { mutableStateOf(false) } + // Trigger dialog automatically when users paste a new valid URL + LaunchedEffect(valueState, isError) { + if (!isError && valueState != channelUrl) { + onConfirm(valueState) + } + } + OutlinedTextField( value = valueState.toString(), onValueChange = {