mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Reuse conversation model when sending and receiving messages
This commit is contained in:
parent
7e22ae310e
commit
43ebb20646
2 changed files with 25 additions and 20 deletions
|
|
@ -248,15 +248,17 @@ class ConversationModel: ObservableObject, Identifiable {
|
|||
|
||||
let lastMessageStateTmp = lastMessage?.state.rawValue ?? 0
|
||||
|
||||
// DispatchQueue.main.async {
|
||||
self.lastMessageText = lastMessageTextTmp
|
||||
|
||||
self.lastMessageIsOutgoing = lastMessageIsOutgoingTmp
|
||||
DispatchQueue.main.async {
|
||||
self.lastMessageText = lastMessageTextTmp
|
||||
|
||||
self.lastMessageIsOutgoing = lastMessageIsOutgoingTmp
|
||||
|
||||
self.lastUpdateTime = lastUpdateTimeTmp
|
||||
|
||||
self.lastMessageState = lastMessageStateTmp
|
||||
}
|
||||
|
||||
self.lastUpdateTime = lastUpdateTimeTmp
|
||||
|
||||
self.lastMessageState = lastMessageStateTmp
|
||||
// }
|
||||
getUnreadMessagesCount()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,19 +316,19 @@ class ConversationModel: ObservableObject, Identifiable {
|
|||
self.chatRoom.participants.forEach { participant in
|
||||
participantsAddressTmp.append(participant.address?.asStringUriOnly() ?? "")
|
||||
}
|
||||
|
||||
// DispatchQueue.main.async {
|
||||
self.subject = subjectTmp
|
||||
self.avatarModel = avatarModelTmp
|
||||
self.participantsAddress = participantsAddressTmp
|
||||
// }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.subject = subjectTmp
|
||||
self.avatarModel = avatarModelTmp
|
||||
self.participantsAddress = participantsAddressTmp
|
||||
}
|
||||
}
|
||||
|
||||
func getUnreadMessagesCount() {
|
||||
let unreadMessagesCountTmp = self.chatRoom.unreadMessagesCount
|
||||
// DispatchQueue.main.async {
|
||||
self.unreadMessagesCount = unreadMessagesCountTmp
|
||||
// }
|
||||
DispatchQueue.main.async {
|
||||
self.unreadMessagesCount = unreadMessagesCountTmp
|
||||
}
|
||||
}
|
||||
|
||||
func refreshAvatarModel() {
|
||||
|
|
|
|||
|
|
@ -189,8 +189,9 @@ class ConversationsListViewModel: ObservableObject {
|
|||
if let defaultAddress = core.defaultAccount?.contactAddress,
|
||||
let localAddress = chatRoom.localAddress,
|
||||
defaultAddress.weakEqual(address2: localAddress) {
|
||||
let model = ConversationModel(chatRoom: chatRoom)
|
||||
let idTmp = LinphoneUtils.getChatRoomId(room: chatRoom)
|
||||
let model = self.conversationsList.first(where: { $0.id == idTmp }) ?? ConversationModel(chatRoom: chatRoom)
|
||||
model.getContentTextMessage(chatRoom: chatRoom)
|
||||
let index = self.conversationsList.firstIndex(where: { $0.id == idTmp })
|
||||
DispatchQueue.main.async {
|
||||
if index != nil {
|
||||
|
|
@ -204,8 +205,9 @@ class ConversationsListViewModel: ObservableObject {
|
|||
if let defaultAddress = core.defaultAccount?.contactAddress,
|
||||
let localAddress = chatRoom.localAddress,
|
||||
defaultAddress.weakEqual(address2: localAddress) {
|
||||
let model = ConversationModel(chatRoom: chatRoom)
|
||||
let idTmp = LinphoneUtils.getChatRoomId(room: chatRoom)
|
||||
let model = self.conversationsList.first(where: { $0.id == idTmp }) ?? ConversationModel(chatRoom: chatRoom)
|
||||
model.getContentTextMessage(chatRoom: chatRoom)
|
||||
let index = self.conversationsList.firstIndex(where: { $0.id == idTmp })
|
||||
if index != nil {
|
||||
self.conversationsList[index!].chatMessageRemoveDelegate()
|
||||
|
|
@ -222,8 +224,9 @@ class ConversationsListViewModel: ObservableObject {
|
|||
if let defaultAddress = core.defaultAccount?.contactAddress,
|
||||
let localAddress = chatRoom.localAddress,
|
||||
defaultAddress.weakEqual(address2: localAddress) {
|
||||
let model = ConversationModel(chatRoom: chatRoom)
|
||||
let idTmp = LinphoneUtils.getChatRoomId(room: chatRoom)
|
||||
let model = self.conversationsList.first(where: { $0.id == idTmp }) ?? ConversationModel(chatRoom: chatRoom)
|
||||
model.getContentTextMessage(chatRoom: chatRoom)
|
||||
let index = self.conversationsList.firstIndex(where: { $0.id == idTmp })
|
||||
DispatchQueue.main.async {
|
||||
if index != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue