diff --git a/Linphone/Contacts/ContactsManager.swift b/Linphone/Contacts/ContactsManager.swift index eba36a0be..ae186df6f 100644 --- a/Linphone/Contacts/ContactsManager.swift +++ b/Linphone/Contacts/ContactsManager.swift @@ -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) } } diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index 81550b380..f3581d75f 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -64,7 +64,9 @@ final class CoreContext: ObservableObject { } } else { coreQueue.async { - lambda(self.mCore) + if self.mCore.globalState != .Off { + lambda(self.mCore) + } } } } diff --git a/Linphone/UI/Main/Conversations/Model/ConversationModel.swift b/Linphone/UI/Main/Conversations/Model/ConversationModel.swift index 439e22fa9..d98124fb4 100644 --- a/Linphone/UI/Main/Conversations/Model/ConversationModel.swift +++ b/Linphone/UI/Main/Conversations/Model/ConversationModel.swift @@ -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 + } } } } diff --git a/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift b/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift index 98b228650..43acefef0 100644 --- a/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift +++ b/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift @@ -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 + } } } }