mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-30 17:36:22 +00:00
Fix updateUIView crash when get old messages in ConversationViewModel
This commit is contained in:
parent
5c82815644
commit
f5c074e0bc
1 changed files with 51 additions and 52 deletions
|
|
@ -62,9 +62,9 @@ class ConversationViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addChatMessageDelegate(message: ChatMessage) {
|
func addChatMessageDelegate(message: ChatMessage) {
|
||||||
coreContext.doOnCoreQueue { _ in
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||||
if self.displayedConversation != nil {
|
if self.displayedConversation != nil {
|
||||||
/*
|
self.coreContext.doOnCoreQueue { _ in
|
||||||
self.chatMessageSuscriptions.insert(message.publisher?.onMsgStateChanged?.postOnCoreQueue {(cbValue: (message: ChatMessage, state: ChatMessage.State)) in
|
self.chatMessageSuscriptions.insert(message.publisher?.onMsgStateChanged?.postOnCoreQueue {(cbValue: (message: ChatMessage, state: ChatMessage.State)) in
|
||||||
var statusTmp: Message.Status? = .sending
|
var statusTmp: Message.Status? = .sending
|
||||||
switch cbValue.message.state {
|
switch cbValue.message.state {
|
||||||
|
|
@ -89,10 +89,8 @@ class ConversationViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
|
|
||||||
self.chatMessageSuscriptions.insert(message.publisher?.onNewMessageReaction?.postOnCoreQueue {(cbValue: (message: ChatMessage, reaction: ChatMessageReaction)) in
|
self.chatMessageSuscriptions.insert(message.publisher?.onNewMessageReaction?.postOnCoreQueue {(cbValue: (message: ChatMessage, reaction: ChatMessageReaction)) in
|
||||||
|
|
||||||
let indexMessage = self.conversationMessagesSection[0].rows.firstIndex(where: {$0.id == message.messageId})
|
let indexMessage = self.conversationMessagesSection[0].rows.firstIndex(where: {$0.id == message.messageId})
|
||||||
var reactionsTmp: [String] = []
|
var reactionsTmp: [String] = []
|
||||||
cbValue.message.reactions.forEach({ chatMessageReaction in
|
cbValue.message.reactions.forEach({ chatMessageReaction in
|
||||||
|
|
@ -124,6 +122,7 @@ class ConversationViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func removeConversationDelegate() {
|
func removeConversationDelegate() {
|
||||||
self.chatRoomSuscriptions.removeAll()
|
self.chatRoomSuscriptions.removeAll()
|
||||||
|
|
@ -312,7 +311,7 @@ class ConversationViewModel: ObservableObject {
|
||||||
|
|
||||||
func getOldMessages() {
|
func getOldMessages() {
|
||||||
coreContext.doOnCoreQueue { _ in
|
coreContext.doOnCoreQueue { _ in
|
||||||
if self.displayedConversation != nil {
|
if self.displayedConversation != nil && self.displayedConversationHistorySize > self.conversationMessagesSection[0].rows.count{
|
||||||
let historyEvents = self.displayedConversation!.chatRoom.getHistoryRangeEvents(begin: self.conversationMessagesSection[0].rows.count, end: self.conversationMessagesSection[0].rows.count + 30)
|
let historyEvents = self.displayedConversation!.chatRoom.getHistoryRangeEvents(begin: self.conversationMessagesSection[0].rows.count, end: self.conversationMessagesSection[0].rows.count + 30)
|
||||||
var conversationMessagesTmp: [Message] = []
|
var conversationMessagesTmp: [Message] = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue