From 4ff03a62e4dc92b3fd337650080362afc2796cad Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Sat, 14 Sep 2024 23:44:22 +0200 Subject: [PATCH] Fix usage of combine framework The sinks have to run in the main queue because they are triggering ui updates (by defaults they run in the queue the nsnotification was sent in). --- Monal/Classes/ContactsView.swift | 2 ++ Monal/Classes/OmemoKeysView.swift | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Monal/Classes/ContactsView.swift b/Monal/Classes/ContactsView.swift index 2eadddaa0..1f9f161a1 100644 --- a/Monal/Classes/ContactsView.swift +++ b/Monal/Classes/ContactsView.swift @@ -184,8 +184,10 @@ class Contacts: ObservableObject { self.requestCount = DataLayer.sharedInstance().allContactRequests().count subscriptions = [ NotificationCenter.default.publisher(for: NSNotification.Name("kMonalContactRemoved")) + .receive(on: DispatchQueue.main) .sink() { _ in self.refreshContacts() }, NotificationCenter.default.publisher(for: NSNotification.Name("kMonalContactRefresh")) + .receive(on: DispatchQueue.main) .sink() { _ in self.refreshContacts() } ] } diff --git a/Monal/Classes/OmemoKeysView.swift b/Monal/Classes/OmemoKeysView.swift index 73cf66c93..7b12671a6 100644 --- a/Monal/Classes/OmemoKeysView.swift +++ b/Monal/Classes/OmemoKeysView.swift @@ -454,8 +454,10 @@ class OmemoKeysForChat: ObservableObject { self.contacts = OmemoKeysForChat.knownDevices(viewContact: self.viewContact) subscriptions = [ NotificationCenter.default.publisher(for: NSNotification.Name("kMonalOmemoStateUpdated")) + .receive(on: DispatchQueue.main) .sink() { _ in self.updateContactDevices() }, NotificationCenter.default.publisher(for: NSNotification.Name("kMonalMucParticipantsAndMembersUpdated")) + .receive(on: DispatchQueue.main) .sink() { _ in self.updateContactDevices() }, ] }