From 21702494826611d4cc6985061827f4164460f6f8 Mon Sep 17 00:00:00 2001 From: Diogo Date: Wed, 20 Nov 2024 22:31:21 +0000 Subject: [PATCH] fix save of custom servers --- .../networkAndServers/NewServerView.kt | 45 ++++++++++--------- .../networkAndServers/ProtocolServersView.kt | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NewServerView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NewServerView.kt index 612a3eb0aa..300ac8ac28 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NewServerView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NewServerView.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.distinctUntilChanged @Composable -fun NewServerView( +fun ModalData.NewServerView( userServers: MutableState>, serverErrors: MutableState>, operatorIndex: Int, @@ -36,7 +36,7 @@ fun NewServerView( val newServer = remember { mutableStateOf(UserServer.empty) } val testing = remember { mutableStateOf(false) } - BackHandler(onBack = { + ModalView(close = { addServer( newServer.value, userServers, @@ -44,26 +44,27 @@ fun NewServerView( rhId, close = close ) - }) - - NewServerLayout( - userServers, - serverErrors, - operatorIndex, - rhId, - newServer, - testing -// testServer = { -// testing = true -// withLongRunningApi { -// val res = testServerConnection(server, m) -// if (isActive) { -// onUpdate(res.first) -// testing = false -// } -// } -// } - ) + close() + }) { + NewServerLayout( + userServers, + serverErrors, + operatorIndex, + rhId, + newServer, + testing + // testServer = { + // testing = true + // withLongRunningApi { + // val res = testServerConnection(server, m) + // if (isActive) { + // onUpdate(res.first) + // testing = false + // } + // } + // } + ) + } if (testing.value) { Box( Modifier.fillMaxSize(), diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt index 1ed0a1eaa6..3f1c117a34 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt @@ -368,7 +368,7 @@ fun showAddServerDialog( Column { SectionItemView({ AlertManager.shared.hideAlert() - ModalManager.start.showModalCloseable { close -> + ModalManager.start.showCustomModal { close -> NewServerView(userServers, serverErrors, operatorIndex, rhId, close) } }) {