From 7e3715593811499c0f660dccd6d3c13672baed25 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:50:24 +0700 Subject: [PATCH] desktop: catching exception while opening non-existing web browser (#3787) * desktop: catching exception while opening non-existing web browser * update strings --------- Co-authored-by: Evgeny Poberezkin --- .../src/commonMain/resources/MR/base/strings.xml | 4 ++++ .../simplex/common/views/call/CallView.desktop.kt | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml b/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml index d9fcbf3a7d..584bcb318f 100644 --- a/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml +++ b/apps/multiplatform/common/src/commonMain/resources/MR/base/strings.xml @@ -806,6 +806,10 @@ connected ended + + Error opening browser + The default web browser is required for calls. Please configure the default browser in the system, and share more information with the developers. + The next generation of private messaging Privacy redefined diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt index 22d39409ed..f35b114740 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/call/CallView.desktop.kt @@ -146,8 +146,21 @@ private fun SendStateUpdates() { @Composable fun WebRTCController(callCommand: SnapshotStateList, onResponse: (WVAPIMessage) -> Unit) { val uriHandler = LocalUriHandler.current + val endCall = { + val call = chatModel.activeCall.value + if (call != null) withBGApi { chatModel.callManager.endCall(call) } + } val server = remember { - uriHandler.openUri("http://${SERVER_HOST}:$SERVER_PORT/simplex/call/") + try { + uriHandler.openUri("http://${SERVER_HOST}:$SERVER_PORT/simplex/call/") + } catch (e: Exception) { + Log.e(TAG, "Unable to open browser: ${e.stackTraceToString()}") + AlertManager.shared.showAlertMsg( + title = generalGetString(MR.strings.unable_to_open_browser_title), + text = generalGetString(MR.strings.unable_to_open_browser_desc) + ) + endCall() + } startServer(onResponse) } fun processCommand(cmd: WCallCommand) {