android: go back to chat list after closing support chat when invitee is pending (#5918)

This commit is contained in:
spaced4ndy
2025-05-16 10:54:13 +00:00
committed by GitHub
parent a92c74d3e5
commit 5e7f77d1d1
2 changed files with 23 additions and 1 deletions

View File

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

View File

@@ -22,6 +22,7 @@ import dev.icerock.moko.resources.compose.stringResource
@Composable
private fun MemberSupportChatView(
chatInfo: ChatInfo,
memberSupportChatsCtx: ChatModel.ChatsContext,
staleChatId: State<String?>,
scrollToItemId: MutableState<Long?>
@@ -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<String?>, 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()