From e07a5a283fc8c116d29e6d63cebd0f8671e114cb Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Sun, 18 Oct 2026 01:34:19 +0000 Subject: [PATCH] desktop: don't open a second badges page or profile form These buttons stay clickable on desktop while their page is shown in another pane, so each click opened another copy: - "Support SimpleX" in the chat's large-file and badge alerts (Badges on the right): the alerts skip while Badges is open, on desktop only, as on Android the page covers the button; - "+ Add profile" in Your chat profiles and "Create chat profile" in the picker (form in the center): skip while the form is on top, keeping what was typed, before asking for authentication; the picker row still hides the picker. --- .../kotlin/chat/simplex/common/views/chat/ComposeView.kt | 2 +- .../kotlin/chat/simplex/common/views/chatlist/UserPicker.kt | 6 +++++- .../chat/simplex/common/views/helpers/ChatInfoImage.kt | 2 +- .../kotlin/chat/simplex/common/views/helpers/ModalView.kt | 3 ++- .../simplex/common/views/usersettings/UserProfilesView.kt | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ComposeView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ComposeView.kt index 357a010d2c..2fb82679e7 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ComposeView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ComposeView.kt @@ -333,7 +333,7 @@ fun showLargeFileAlert(fileSize: Long, incognito: Boolean, senderProfile: LocalP text = text, confirmText = generalGetString(MR.strings.ok), dismissText = generalGetString(MR.strings.badges_support_simplex_title), - onDismiss = ::openBadgesView + onDismiss = { if (!appPlatform.isDesktop || !ModalManager.end.hasModalOpen(ModalViewId.BADGES)) openBadgesView() } ) } else { AlertManager.shared.showAlertMsg(title, text) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt index ea567d7da6..e3f6b92be8 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt @@ -274,8 +274,12 @@ fun UserPicker( painterResource(MR.images.ic_manage_accounts), generalGetString(MR.strings.create_chat_profile), { + if (ModalManager.center.isTopModalOpen(ModalViewId.CREATE_PROFILE)) { + userPickerState.value = AnimatedViewState.HIDING + return@UserPickerOptionRow + } doWithAuth(generalGetString(MR.strings.auth_open_chat_profiles), generalGetString(MR.strings.auth_log_in_using_credential)) { - ModalManager.center.showModalCloseable { close -> + ModalManager.center.showModalCloseable(id = ModalViewId.CREATE_PROFILE) { close -> LaunchedEffect(Unit) { userPickerState.value = AnimatedViewState.HIDING } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt index 036bcab68d..b09efe7d1d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt @@ -252,7 +252,7 @@ fun showBadgeInfoAlert(name: String, badge: LocalBadge, uriHandler: UriHandler) text = supports, confirmText = generalGetString(MR.strings.ok), dismissText = generalGetString(MR.strings.badges_support_simplex_title), - onDismiss = ::openBadgesView + onDismiss = { if (!appPlatform.isDesktop || !ModalManager.end.hasModalOpen(ModalViewId.BADGES)) openBadgesView() } ) } else { AlertManager.shared.showAlertMsg(title = title, text = supports) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ModalView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ModalView.kt index 0126156900..fe6c8bfa42 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ModalView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ModalView.kt @@ -94,7 +94,8 @@ enum class ModalViewId { CONTEXT_USER_PICKER_INCOGNITO, BADGE_LINK, BADGE_REDEEM_CODE, - BADGES + BADGES, + CREATE_PROFILE } class ModalManager(private val placement: ModalPlacement? = null) { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/UserProfilesView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/UserProfilesView.kt index e91d6c2ce0..5d8ecec60b 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/UserProfilesView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/UserProfilesView.kt @@ -47,8 +47,9 @@ fun UserProfilesView(m: ChatModel, search: MutableState, profileHidden: showHiddenProfilesNotice = m.controller.appPrefs.showHiddenProfilesNotice, visibleUsersCount = visibleUsersCount(m), addUser = { + if (ModalManager.center.isTopModalOpen(ModalViewId.CREATE_PROFILE)) return@UserProfilesLayout withAuth { - ModalManager.center.showModalCloseable { close -> + ModalManager.center.showModalCloseable(id = ModalViewId.CREATE_PROFILE) { close -> CreateProfile(m, close) } }