mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-04 15:07:32 +00:00
android, desktop: keep group link changes made just before Back
The group info is not shown while the "Group link" page is open over it, and is shown anew after Back. A link created or deleted on that page finishes in the background: when Back came first, the info was shown with the link as it was before, and the late result went to the info shown earlier, so it offered "Create group link" for a group that has a link, or "Group link" for one that has none, until it was shown again. Keep the loaded group link as state the info reads, so a late result reaches the info that is shown.
This commit is contained in:
1 parent
ceb13f3a0a
commit
dfe0dfdb55
1 file changed
+5
-8
+5
-8
@@ -408,14 +408,14 @@ fun ChatView(
|
||||
// The idea is to preload information before showing a modal because large groups can take time to load all members
|
||||
var preloadedContactInfo: Pair<ConnectionStats?, Profile?>? = null
|
||||
var preloadedCode: String? = null
|
||||
var preloadedLink: GroupLink? = null
|
||||
val preloadedLink = mutableStateOf<GroupLink?>(null)
|
||||
var preloadedChatId: ChatId? = chatInfo.id
|
||||
if (chatInfo is ChatInfo.Direct) {
|
||||
preloadedContactInfo = chatModel.controller.apiContactInfo(chatRh, chatInfo.apiId)
|
||||
preloadedCode = chatModel.controller.apiGetContactCode(chatRh, chatInfo.apiId)?.second
|
||||
} else if (chatInfo is ChatInfo.Group) {
|
||||
setGroupMembers(chatRh, chatInfo.groupInfo, chatModel)
|
||||
preloadedLink = chatModel.controller.apiGetGroupLink(chatRh, chatInfo.groupInfo.groupId)
|
||||
preloadedLink.value = chatModel.controller.apiGetGroupLink(chatRh, chatInfo.groupInfo.groupId)
|
||||
}
|
||||
if (!isActive) return@launch
|
||||
|
||||
@@ -440,20 +440,17 @@ fun ChatView(
|
||||
showSearch.value = true
|
||||
}
|
||||
} else if (chatInfo is ChatInfo.Group) {
|
||||
var link: GroupLink? by remember(chatInfo.id) { mutableStateOf(if (chatInfo.id == preloadedChatId) preloadedLink else null) }
|
||||
var linkLoaded by remember(chatInfo.id) { mutableStateOf(chatInfo.id == preloadedChatId) }
|
||||
LaunchedEffect(chatInfo.id) {
|
||||
if (chatInfo.id == preloadedChatId && chatModel.membersLoaded.value) return@LaunchedEffect
|
||||
preloadedChatId = null
|
||||
setGroupMembers(chatRh, chatInfo.groupInfo, chatModel)
|
||||
link = chatModel.controller.apiGetGroupLink(chatRh, chatInfo.groupInfo.groupId)
|
||||
preloadedLink.value = chatModel.controller.apiGetGroupLink(chatRh, chatInfo.groupInfo.groupId)
|
||||
linkLoaded = true
|
||||
preloadedLink = link
|
||||
preloadedChatId = chatInfo.id
|
||||
}
|
||||
GroupChatInfoView(chatsCtx, chatRh, chatInfo.id, link, linkLoaded, selectedItems, appBar, scrollToItemId, {
|
||||
link = it
|
||||
if (chatInfo.id == preloadedChatId) preloadedLink = it
|
||||
GroupChatInfoView(chatsCtx, chatRh, chatInfo.id, if (linkLoaded) preloadedLink.value else null, linkLoaded, selectedItems, appBar, scrollToItemId, {
|
||||
if (chatInfo.id == preloadedChatId) preloadedLink.value = it
|
||||
}, close, { showSearch.value = true })
|
||||
} else {
|
||||
LaunchedEffect(Unit) {
|
||||
|
||||
Reference in new issue
Block a user