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) {