ios: close support chat for invitee when accepted (#5873)

This commit is contained in:
spaced4ndy
2025-05-07 07:37:17 +00:00
committed by GitHub
parent 3c36b0c692
commit d087059153
3 changed files with 14 additions and 1 deletions
+1
View File
@@ -387,6 +387,7 @@ final class ChatModel: ObservableObject {
// ItemsModel for secondary chat view (such as support scope chat), as opposed to ItemsModel.shared used for primary chat
@Published var secondaryIM: ItemsModel? = nil
@Published var secondaryPendingInviteeChatOpened = false
static var ok: Bool { ChatModel.shared.chatDbStatus == .ok }
+7 -1
View File
@@ -2285,11 +2285,17 @@ func processReceivedMsg(_ res: ChatEvent) async {
}
}
case let .userJoinedGroup(user, groupInfo):
// TODO [knocking] close support scope for this group if it's currently opened
if active(user) {
await MainActor.run {
m.updateGroup(groupInfo)
}
if m.chatId == groupInfo.id,
case .memberSupport(nil) = m.secondaryIM?.groupScopeInfo {
await MainActor.run {
m.secondaryPendingInviteeChatOpened = false
m.secondaryIM = nil
}
}
}
case let .joinedGroupMember(user, groupInfo, member):
if active(user) {
@@ -234,6 +234,7 @@ struct ChatView: View {
groupInfo.membership.memberPending {
let secIM = ItemsModel(secondaryIMFilter: .groupChatScopeContext(groupScopeInfo: userSupportScopeInfo))
secIM.loadOpenChat(chat.id) {
chatModel.secondaryPendingInviteeChatOpened = true
showUserSupportChatSheet = true
}
}
@@ -268,6 +269,11 @@ struct ChatView: View {
dismiss()
}
}
.onChange(of: chatModel.secondaryPendingInviteeChatOpened) { opened in
if im.secondaryIMFilter != nil && !opened {
dismiss()
}
}
.onChange(of: chatModel.openAroundItemId) { openAround in
if let openAround {
closeSearch()