Fix notification click redirection to chatroom

This commit is contained in:
benoit.martins 2025-02-06 22:34:44 +01:00
parent db24bd842f
commit 56f732144d
2 changed files with 15 additions and 8 deletions

View file

@ -28,6 +28,8 @@ struct ConversationFragment: View {
@State private var orientation = UIDevice.current.orientation
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
@EnvironmentObject var navigationManager: NavigationManager
@ObservedObject var contactsManager = ContactsManager.shared
@ObservedObject private var sharedMainViewModel = SharedMainViewModel.shared
@ -165,10 +167,12 @@ struct ConversationFragment: View {
}
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
if conversationViewModel.displayedConversation != nil && (navigationManager.peerAddr == nil || navigationManager.peerAddr!.contains(conversationViewModel.displayedConversation!.remoteSipUri)) {
conversationViewModel.resetDisplayedChatRoom()
}
}
}
}
.navigationViewStyle(.stack)
}

View file

@ -1777,19 +1777,22 @@ class ConversationViewModel: ObservableObject {
self.selectedMessage = nil
self.resetMessage()
self.removeConversationDelegate()
withAnimation {
self.displayedConversation = conversationModel
}
CoreContext.shared.doOnCoreQueue { core in
let nilParams: ConferenceParams? = nil
if let newChatRoom = core.searchChatRoom(params: nilParams, localAddr: nil, remoteAddr: conversationModel.chatRoom.peerAddress, participants: nil) {
if LinphoneUtils.getChatRoomId(room: newChatRoom) == conversationModel.id {
self.addConversationDelegate(chatRoom: newChatRoom)
let conversation = ConversationModel(chatRoom: newChatRoom)
DispatchQueue.main.async {
withAnimation {
self.displayedConversation = conversation
}
}
self.getMessages()
}
}
}
}
}
func resetDisplayedChatRoom() {
if !self.conversationMessagesSection.isEmpty && !self.conversationMessagesSection[0].rows.isEmpty {