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 0b5d9ae4ec..79c27912ff 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 @@ -119,8 +119,7 @@ fun TestServersButton( SectionItemView( { scope.launch { - testServers(testing, smpServers, chatModel) { onUpdate(ServerProtocol.SMP, it) } - testServers(testing, xftpServers, chatModel) { onUpdate(ServerProtocol.XFTP, it) } + testServers(testing, smpServers, xftpServers, chatModel, onUpdate) } }, disabled = disabled.value @@ -200,12 +199,22 @@ fun InvalidServer() { Icon(painterResource(MR.images.ic_error), null, tint = MaterialTheme.colors.error) } -private suspend fun testServers(testing: MutableState, servers: List, m: ChatModel, onUpdated: (List) -> Unit) { - val resetStatus = resetTestStatus(servers) - onUpdated(resetStatus) +private suspend fun testServers( + testing: MutableState, + smpServers: List, + xftpServers: List, + m: ChatModel, + onUpdate: (ServerProtocol, List) -> Unit +) { + val smpResetStatus = resetTestStatus(smpServers) + onUpdate(ServerProtocol.SMP, smpResetStatus) + val xftpResetStatus = resetTestStatus(xftpServers) + onUpdate(ServerProtocol.XFTP, xftpResetStatus) testing.value = true - val fs = runServersTest(resetStatus, m) { onUpdated(it) } + val smpFailures = runServersTest(smpResetStatus, m) { onUpdate(ServerProtocol.SMP, it) } + val xftpFailures = runServersTest(xftpResetStatus, m) { onUpdate(ServerProtocol.XFTP, it) } testing.value = false + val fs = smpFailures + xftpFailures if (fs.isNotEmpty()) { val msg = fs.map { it.key + ": " + it.value.localizedDescription }.joinToString("\n") AlertManager.shared.showAlertMsg(