From eeb8c94c699953f0ec81528ece59f57a04779c4f Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Fri, 10 May 2024 09:54:55 +0200 Subject: [PATCH] Start and stop core in sync queue --- Linphone/Contacts/ContactsManager.swift | 4 +--- Linphone/Core/CoreContext.swift | 6 ++---- Linphone/LinphoneApp.swift | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Linphone/Contacts/ContactsManager.swift b/Linphone/Contacts/ContactsManager.swift index 0cbc6e925..a228dbb5b 100644 --- a/Linphone/Contacts/ContactsManager.swift +++ b/Linphone/Contacts/ContactsManager.swift @@ -41,9 +41,7 @@ final class ContactsManager: ObservableObject { private var friendListSuscription: AnyCancellable? - private init() { - fetchContacts() - } + private init() {} func fetchContacts() { coreContext.doOnCoreQueue { core in diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index 899f974d3..3a345aee7 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -247,8 +247,6 @@ final class CoreContext: ObservableObject { .sink { _ in self.mCore.iterate() } - - try? self.mCore.start() } } @@ -259,7 +257,7 @@ final class CoreContext: ObservableObject { } func onEnterForeground() { - coreQueue.async { + coreQueue.sync { // We can't rely on defaultAccount?.params?.isPublishEnabled // as it will be modified by the SDK when changing the presence status @@ -270,7 +268,7 @@ final class CoreContext: ObservableObject { } func onEnterBackground() { - coreQueue.async { + coreQueue.sync { // We can't rely on defaultAccount?.params?.isPublishEnabled // as it will be modified by the SDK when changing the presence status Log.info("App is in background, un-PUBLISHING presence info") diff --git a/Linphone/LinphoneApp.swift b/Linphone/LinphoneApp.swift index e0baf7f60..0b018c617 100644 --- a/Linphone/LinphoneApp.swift +++ b/Linphone/LinphoneApp.swift @@ -144,6 +144,7 @@ struct LinphoneApp: App { if newPhase == .active { Log.info("Entering foreground") coreContext.onEnterForeground() + ContactsManager.shared.fetchContacts() } else if newPhase == .inactive { } else if newPhase == .background { Log.info("Entering background")