mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 10:43:05 +00:00
ui: create one group on a double click of Create group (#7759)
* desktop: open a pending connection's "Learn more" and "Incognito" pages once
On desktop the connection view stays clickable in the center pane, so each
click on these rows pushed another modal onto the right pane. Close the
right-pane modals first, as ChatView does when the connection opens. The page
is closed and shown again in one event, so its content is keyed by its
ModalData to start fresh.
Desktop only: on Android the view can itself be the open modal of the shared
manager ("Set contact name"), and the new page already covers the row.
Fixes #6270
* ui: open a modal once when its button is double-clicked
A modal slides in over 250 ms, and until it covers the button that opened it the button still takes clicks, so a double click opened two copies (left-pane pages and most stacked center and right-pane pages on desktop, animated modals on Android). When a modal opens, the page it covers draws an empty pointerInput box over itself while it slides out; when a pane's first modal slides in, the empty page sliding out covers the view under the pane. The page sliding in already takes clicks, and nothing is blocked when a page closes.
* ui: add isTopModalOpen, which ignores modals that are sliding out
A modal closed with animation stays in modalViews until it has slid out, and isLastModalOpen counts it. A check-then-closeModal() on it would close the modal under it. Uses the same index as isLastModal; isLastModalOpen and its callers are unchanged.
* 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.
* desktop: replace a page of the same kind on top instead of stacking another
These buttons stay clickable on desktop while their page is shown in another pane, so each click pushed another copy:
- the chat banner's bio "Read more" (right pane);
- a markdown file clicked in a support chat (viewer in the center);
- message "Info" in the main chat while a support or reports chat is open on the right.
Their content depends on what was clicked and the pane can hold other pages (a support chat), so a page of the same kind on top is replaced. The new page is drawn where the old one was, so its content is keyed by its ModalData to start fresh. The markdown file and Info load on a background thread; their close and show now run on the main thread. The markdown check is desktop only, as on Android the viewer covers its file once it has loaded.
* plans: a page opens again on every click of its button (#6270)
* ui: create one group on a double click of Create group
"Create group" creates the group, opens it and only then closes its
page, and the core does not deduplicate, so a double click created two
groups. The page now ignores a click while its create is in progress,
on desktop and Android.
* plans: a double click on "create group" creates two groups
* plans: D2 is valid at 80 ms only
* ui: ignore a click on Create group until its page has closed after a create
This commit is contained in:
1 parent
cc3f49f794
commit
cfcce1b43c
2 files changed
+25
No files matched your search
+5
@@ -39,8 +39,11 @@ import java.net.URI
|
||||
fun AddGroupView(chatModel: ChatModel, rh: RemoteHostInfo?, close: () -> Unit, closeAll: () -> Unit) {
|
||||
val rhId = rh?.remoteHostId
|
||||
val view = LocalMultiplatformView()
|
||||
val inProgress = remember { mutableStateOf(false) }
|
||||
AddGroupLayout(
|
||||
createGroup = { incognito, groupProfile ->
|
||||
if (inProgress.value) return@AddGroupLayout
|
||||
inProgress.value = true
|
||||
hideKeyboard(view)
|
||||
withBGApi {
|
||||
val groupInfo = chatModel.controller.apiNewGroup(rhId, incognito, groupProfile)
|
||||
@@ -61,6 +64,8 @@ fun AddGroupView(chatModel: ChatModel, rh: RemoteHostInfo?, close: () -> Unit, c
|
||||
GroupLinkView(chatModel, rhId, groupInfo, groupLink = null, onGroupLinkUpdated = null, creatingGroup = true, close = close)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inProgress.value = false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# A double click on "Create group" creates two groups
|
||||
|
||||
Follow-up to #7725.
|
||||
|
||||
## Problem
|
||||
|
||||
"Create group" creates the group (`apiNewGroup`), opens it, loads its members and only then closes its page and opens Invite members (or the group link when incognito). The button stays enabled meanwhile and the core does not deduplicate, so a double click created two groups (the second named with a suffix, for example "G2_1"). Reproduced on the master prebuild at 40, 80 and 150 ms.
|
||||
|
||||
## Fix
|
||||
|
||||
The page remembers whether its create is in progress, as `CIGroupInvitationView` does for joining: the create handler checks and sets it at the start, so a second click on that page while it is set is ignored. It is cleared only when the create fails. A successful create closes the page, but the page leaves the screen only after its job has ended (in testing the job ended about 0.7 s after the click and the page was gone 0.8 to 1.1 s after it), so clearing it at the end of the job let a second click in that gap create a second group.
|
||||
|
||||
## Not fixed
|
||||
|
||||
- The channel's "Continue" (desktop `onLinkReady`) was checked and not affected: a double click opened one link page in testing.
|
||||
- A create that never returns, or that throws instead of returning an error, keeps that page's "Create group" inert; a page opened again creates as on master.
|
||||
|
||||
## Effect
|
||||
|
||||
Desktop and Android: one group per double click. After a failed create the button works again. Single clicks are unchanged.
|
||||
Reference in new issue
Block a user