From d4b10d38ae10edc9fd9faa8cbbd516a6bd7dde52 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Wed, 17 Dec 2025 11:48:51 +0100 Subject: [PATCH] Use CorePreferences contactsFilter for contact filtering --- Linphone/Core/CoreContext.swift | 5 ----- Linphone/GeneratedGit.swift | 2 +- Linphone/UI/Main/ContentView.swift | 2 +- Linphone/Utils/MagicSearchSingleton.swift | 19 +++++++------------ 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index 92cb23619..2f0222d12 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -248,11 +248,6 @@ class CoreContext: ObservableObject { } } - // TODO: Temporary workaround until SDK fixs - if CorePreferences.defaultDomain == "" { - CorePreferences.defaultDomain = core.defaultAccount?.params?.domain ?? "" - } - self.actionsToPerformOnCoreQueueWhenCoreIsStarted.forEach { $0(core) } self.actionsToPerformOnCoreQueueWhenCoreIsStarted.removeAll() diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index 82ab9c663..c05dba1a8 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -2,6 +2,6 @@ import Foundation public enum AppGitInfo { public static let branch = "master" - public static let commit = "ed08190ff" + public static let commit = "6827bdc1d" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index b59099da2..f837974f8 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -594,7 +594,7 @@ struct ContentView: View { magicSearch.searchForContacts() } label: { HStack { - Text(magicSearch.domainDefaultAccount == "*" ? String(localized: "contacts_list_filter_popup_see_sip_only") : String(format: String(localized: "contacts_list_filter_popup_see_linphone_only"), Bundle.main.displayName)) + Text(!magicSearch.linphoneDomain ? String(localized: "contacts_list_filter_popup_see_sip_only") : String(format: String(localized: "contacts_list_filter_popup_see_linphone_only"), Bundle.main.displayName)) Spacer() if !magicSearch.allContact { Image("green-check") diff --git a/Linphone/Utils/MagicSearchSingleton.swift b/Linphone/Utils/MagicSearchSingleton.swift index e38dcf5fd..5031e65e5 100644 --- a/Linphone/Utils/MagicSearchSingleton.swift +++ b/Linphone/Utils/MagicSearchSingleton.swift @@ -36,9 +36,9 @@ final class MagicSearchSingleton: ObservableObject { private var limitSearchToLinphoneAccounts = true - @Published var allContact = false - let allContactKey = "all_contact" + @Published var allContact = true + var linphoneDomain = true var domainDefaultAccount = "" var searchDelegate: MagicSearchDelegate? @@ -56,15 +56,11 @@ final class MagicSearchSingleton: ObservableObject { } private init() { - let preferences = UserDefaults.standard - if preferences.object(forKey: allContactKey) == nil { - preferences.set(allContact, forKey: allContactKey) - } else { - allContact = preferences.bool(forKey: allContactKey) - } + allContact = CorePreferences.contactsFilter == "" coreContext.doOnCoreQueue { core in - self.domainDefaultAccount = (core.defaultAccount?.params?.domain?.contains("sip.linphone.org") == true) ? (core.defaultAccount?.params?.domain ?? "") : "*" + self.linphoneDomain = CorePreferences.defaultDomain == core.defaultAccount?.params?.domain + self.domainDefaultAccount = CorePreferences.contactsFilter self.magicSearch = try? core.createMagicSearch() @@ -161,10 +157,9 @@ final class MagicSearchSingleton: ObservableObject { } func changeAllContact(allContactBool: Bool) { - let preferences = UserDefaults.standard - allContact = allContactBool - preferences.set(allContact, forKey: allContactKey) + domainDefaultAccount = allContactBool ? "" : (linphoneDomain ? CorePreferences.defaultDomain : "*") + CorePreferences.contactsFilter = domainDefaultAccount } func updateContacts(