mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Fix updating of chat room list
This commit is contained in:
parent
baf1fcc0b9
commit
4b2f10280e
3 changed files with 24 additions and 17 deletions
|
|
@ -306,7 +306,10 @@ class ConversationModel: ObservableObject, Identifiable {
|
|||
|
||||
func getUnreadMessagesCount() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
self.unreadMessagesCount = self.chatRoom.unreadMessagesCount
|
||||
let unreadMessagesCountTmp = self.chatRoom.unreadMessagesCount
|
||||
DispatchQueue.main.async {
|
||||
self.unreadMessagesCount = unreadMessagesCountTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,20 @@ class ConversationViewModel: ObservableObject {
|
|||
self.getNewMessages(eventLogs: [eventLogs])
|
||||
}, onSubjectChanged: { (_: ChatRoom, eventLogs: EventLog) in
|
||||
self.getNewMessages(eventLogs: [eventLogs])
|
||||
}, onConferenceJoined: {(_: ChatRoom, eventLog: EventLog) in
|
||||
self.getNewMessages(eventLogs: [eventLog])
|
||||
if self.displayedConversation != nil {
|
||||
DispatchQueue.main.async {
|
||||
self.displayedConversation!.isReadOnly = false
|
||||
}
|
||||
}
|
||||
}, onConferenceLeft: {(_: ChatRoom, eventLog: EventLog) in
|
||||
self.getNewMessages(eventLogs: [eventLog])
|
||||
if self.displayedConversation != nil {
|
||||
DispatchQueue.main.async {
|
||||
self.displayedConversation!.isReadOnly = true
|
||||
}
|
||||
}
|
||||
}, onEphemeralEvent: {(_: ChatRoom, eventLogs: EventLog) in
|
||||
self.getNewMessages(eventLogs: [eventLogs])
|
||||
}, onEphemeralMessageDeleted: {(_: ChatRoom, eventLog: EventLog) in
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class ConversationsListViewModel: ObservableObject {
|
|||
coreContext.doOnCoreQueue { core in
|
||||
let account = core.defaultAccount
|
||||
let chatRoomsCounter = account?.chatRooms != nil ? account!.chatRooms.count : core.chatRooms.count
|
||||
var counter = 0
|
||||
|
||||
self.coreConversationDelegate = CoreDelegateStub(onMessagesReceived: { (_: Core, _: ChatRoom, _: [ChatMessage]) in
|
||||
self.computeChatRoomsList(filter: "")
|
||||
|
|
@ -76,24 +75,15 @@ class ConversationsListViewModel: ObservableObject {
|
|||
self.computeChatRoomsList(filter: "")
|
||||
}, onChatRoomRead: { (_: Core, _: ChatRoom) in
|
||||
self.computeChatRoomsList(filter: "")
|
||||
}, onChatRoomStateChanged: { (_: Core, chatRoom: ChatRoom, state: ChatRoom.State) in
|
||||
}, onChatRoomStateChanged: { (core: Core, chatRoom: ChatRoom, state: ChatRoom.State) in
|
||||
// Log.info("[ConversationsListViewModel] Conversation [${LinphoneUtils.getChatRoomId(chatRoom)}] state changed [$state]")
|
||||
switch state {
|
||||
case ChatRoom.State.Created:
|
||||
if !(chatRoom.isEmpty && chatRoom.hasCapability(mask: ChatRoom.Capabilities.OneToOne.rawValue)) {
|
||||
counter += 1
|
||||
}
|
||||
|
||||
if counter >= chatRoomsCounter {
|
||||
if core.globalState == .On {
|
||||
switch state {
|
||||
case .Created, .Deleted, .Terminated:
|
||||
self.computeChatRoomsList(filter: "")
|
||||
counter = 0
|
||||
default:
|
||||
break
|
||||
}
|
||||
case ChatRoom.State.Deleted:
|
||||
self.computeChatRoomsList(filter: "")
|
||||
// ToastViewModel.shared.toastMessage = "toast_conversation_deleted"
|
||||
// ToastViewModel.shared.displayToast = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
core.addDelegate(delegate: self.coreConversationDelegate!)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue