From e88927ee1fa7561824028b4f50733c2154731d84 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Sat, 4 Oct 2025 12:09:07 +0000 Subject: [PATCH] android: fix showing connection alert when app is opened via link (#6333) * android: fix showing connection alert when app is opened via link * opened on onboarding * cleanup logs * cleanup logs * restore log --- .../src/commonMain/kotlin/chat/simplex/common/App.kt | 4 ++-- .../kotlin/chat/simplex/common/model/ChatModel.kt | 1 + .../chat/simplex/common/views/chatlist/ChatListView.kt | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt index d88a450fd1..70e0067260 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt @@ -243,9 +243,9 @@ fun MainScreen() { ModalManager.fullscreen.showOneTimePasscodeInView() AlertManager.privacySensitive.showInView() if (onboarding == OnboardingStage.OnboardingComplete) { - LaunchedEffect(chatModel.currentUser.value, chatModel.appOpenUrl.value) { + LaunchedEffect(chatModel.chatRunning.value, chatModel.currentUser.value, chatModel.appOpenUrl.value) { val (rhId, url) = chatModel.appOpenUrl.value ?: (null to null) - if (url != null) { + if (url != null && chatModel.chatRunning.value == true) { chatModel.appOpenUrl.value = null connectIfOpenedViaUri(rhId, url, chatModel) } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index 628e768d57..76a9ab4c16 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -133,6 +133,7 @@ object ChatModel { // set when app is opened via contact or invitation URI (rhId, uri) val appOpenUrl = mutableStateOf?>(null) + val appOpenUrlConnecting = mutableStateOf(false) // Needed to check for bottom nav bar and to apply or not navigation bar color on Android val newChatSheetVisible = mutableStateOf(false) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt index 7b5be0c323..2109e21bfe 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt @@ -601,7 +601,8 @@ fun connectIfOpenedViaUri(rhId: Long?, uri: String, chatModel: ChatModel) { chatModel.appOpenUrl.value = rhId to uri } else { withBGApi { - planAndConnect(rhId, uri, close = null) + chatModel.appOpenUrlConnecting.value = true + planAndConnect(rhId, uri, close = null, cleanup = { chatModel.appOpenUrlConnecting.value = false }) } } } @@ -670,7 +671,9 @@ private fun ChatListSearchBar(listState: LazyListState, searchText: MutableState // if some other text is pasted, enter search mode focusRequester.requestFocus() } else { - connectProgressManager.cancelConnectProgress() + if (!chatModel.appOpenUrlConnecting.value) { + connectProgressManager.cancelConnectProgress() + } if (listState.layoutInfo.totalItemsCount > 0) { listState.scrollToItem(0) }