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.
This commit is contained in:
Narasimha-sc committed 2026-10-18 01:34:19 +00:00
1 parent abb06e9f10
commit e07a5a283f
5 files changed
+11 -5

No files matched your search

@@ -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)
@@ -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
}
@@ -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)
@@ -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) {
@@ -47,8 +47,9 @@ fun UserProfilesView(m: ChatModel, search: MutableState<String>, 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)
}
}