forked from mirrors/linphone-iphone
Check core state before using an asynchronous function
Fix markAsRead crash
This commit is contained in:
parent
7dca3300e1
commit
00a7f305a5
4 changed files with 18 additions and 8 deletions
|
|
@ -145,8 +145,7 @@ final class ContactsManager: ObservableObject {
|
|||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
self.friendListSuscription = nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ final class CoreContext: ObservableObject {
|
|||
}
|
||||
} else {
|
||||
coreQueue.async {
|
||||
lambda(self.mCore)
|
||||
if self.mCore.globalState != .Off {
|
||||
lambda(self.mCore)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,11 +109,15 @@ class ConversationModel: ObservableObject {
|
|||
|
||||
func markAsRead() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
self.chatRoom.markAsRead()
|
||||
|
||||
let unreadMessagesCountTmp = self.chatRoom.unreadMessagesCount
|
||||
if unreadMessagesCountTmp > 0 {
|
||||
self.chatRoom.markAsRead()
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.unreadMessagesCount = unreadMessagesCountTmp
|
||||
if self.unreadMessagesCount != unreadMessagesCountTmp {
|
||||
self.unreadMessagesCount = unreadMessagesCountTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,10 +85,15 @@ class ConversationViewModel: ObservableObject {
|
|||
|
||||
func markAsRead() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
self.displayedConversation!.chatRoom.markAsRead()
|
||||
let unreadMessagesCount = self.displayedConversation!.chatRoom.unreadMessagesCount
|
||||
|
||||
if unreadMessagesCount > 0 {
|
||||
self.displayedConversation!.chatRoom.markAsRead()
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
self.displayedConversationUnreadMessagesCount = unreadMessagesCount
|
||||
if self.displayedConversationUnreadMessagesCount != unreadMessagesCount {
|
||||
self.displayedConversationUnreadMessagesCount = unreadMessagesCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue