From dfe0dfdb55415ca7deee8d3f4c84060c9fa9397a Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Sat, 17 Oct 2026 18:10:27 +0000 Subject: [PATCH] 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. --- .../chat/simplex/common/views/chat/ChatView.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 0524cd4dfb..7fae51c126 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -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? = null var preloadedCode: String? = null - var preloadedLink: GroupLink? = null + val preloadedLink = mutableStateOf(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) {