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
This commit is contained in:
spaced4ndy
2025-10-04 13:09:07 +01:00
committed by GitHub
parent 84dd294983
commit e88927ee1f
3 changed files with 8 additions and 4 deletions
@@ -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)
}
@@ -133,6 +133,7 @@ object ChatModel {
// set when app is opened via contact or invitation URI (rhId, uri)
val appOpenUrl = mutableStateOf<Pair<Long?, String>?>(null)
val appOpenUrlConnecting = mutableStateOf<Boolean>(false)
// Needed to check for bottom nav bar and to apply or not navigation bar color on Android
val newChatSheetVisible = mutableStateOf(false)
@@ -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)
}