From 5e7f77d1d16010e6635c2a2e4aec4e8285efadda Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 16 May 2025 10:54:13 +0000 Subject: [PATCH] android: go back to chat list after closing support chat when invitee is pending (#5918) --- .../chat/simplex/common/model/ChatModel.kt | 6 ++++++ .../views/chat/group/MemberSupportChatView.kt | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index f50b4a99ca..2a47e22be8 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -323,6 +323,12 @@ object ChatModel { is SecondaryContextFilter.MsgContentTagContext -> null } + val isUserSupportChat: Boolean = + when (groupScopeInfo) { + null -> false + is GroupChatScopeInfo.MemberSupport -> groupScopeInfo.groupMember_ == null + } + suspend fun addChat(chat: Chat) { chats.add(index = 0, chat) popChatCollector.throttlePopChat(chat.remoteHostId, chat.id, currentPosition = 0) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/MemberSupportChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/MemberSupportChatView.kt index 3196cae15c..99e2e3198e 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/MemberSupportChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/MemberSupportChatView.kt @@ -22,6 +22,7 @@ import dev.icerock.moko.resources.compose.stringResource @Composable private fun MemberSupportChatView( + chatInfo: ChatInfo, memberSupportChatsCtx: ChatModel.ChatsContext, staleChatId: State, scrollToItemId: MutableState @@ -29,6 +30,21 @@ private fun MemberSupportChatView( KeyChangeEffect(chatModel.chatId.value) { ModalManager.end.closeModals() } + if (appPlatform.isAndroid) { + DisposableEffect(Unit) { + onDispose { + val chat = chatModel.chats.value.firstOrNull { ch -> ch.id == chatInfo.id } + if ( + memberSupportChatsCtx.isUserSupportChat + && chat?.chatInfo?.groupInfo_?.membership?.memberPending == true + ) { + withBGApi { + chatModel.chatId.value = null + } + } + } + } + } ChatView(memberSupportChatsCtx, staleChatId, scrollToItemId, onComposed = {}) } @@ -118,7 +134,7 @@ suspend fun showMemberSupportChatView(staleChatId: State, scrollToItemI ModalManager.end.showCustomModal(true, id = ModalViewId.SECONDARY_CHAT) { close -> ModalView({}, showAppBar = false) { if (chatInfo is ChatInfo.Group && chatInfo.groupChatScope != null) { - MemberSupportChatView(memberSupportChatsCtx, staleChatId, scrollToItemId) + MemberSupportChatView(chatInfo, memberSupportChatsCtx, staleChatId, scrollToItemId) } else { LaunchedEffect(Unit) { close()