mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Store magicSearch.allContacts to display the entire contact list when the app starts
This commit is contained in:
parent
bb4134ede0
commit
8c9784a21d
2 changed files with 18 additions and 2 deletions
|
|
@ -522,7 +522,7 @@ struct ContentView: View {
|
|||
Button {
|
||||
sharedMainViewModel.displayedFriend = nil
|
||||
isMenuOpen = false
|
||||
magicSearch.allContact = true
|
||||
magicSearch.changeAllContact(allContactBool: true)
|
||||
magicSearch.searchForContacts()
|
||||
} label: {
|
||||
HStack {
|
||||
|
|
@ -540,7 +540,7 @@ struct ContentView: View {
|
|||
Button {
|
||||
sharedMainViewModel.displayedFriend = nil
|
||||
isMenuOpen = false
|
||||
magicSearch.allContact = false
|
||||
magicSearch.changeAllContact(allContactBool: false)
|
||||
magicSearch.searchForContacts()
|
||||
} label: {
|
||||
HStack {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
private var limitSearchToLinphoneAccounts = true
|
||||
|
||||
@Published var allContact = false
|
||||
let allContactKey = "all_contact"
|
||||
|
||||
private var domainDefaultAccount = ""
|
||||
|
||||
var searchDelegate: MagicSearchDelegate?
|
||||
|
|
@ -52,6 +54,13 @@ 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)
|
||||
}
|
||||
|
||||
coreContext.doOnCoreQueue { core in
|
||||
self.domainDefaultAccount = core.defaultAccount?.params?.domain ?? ""
|
||||
|
||||
|
|
@ -148,6 +157,13 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
magicSearch.addDelegate(delegate: self.searchDelegate!)
|
||||
}
|
||||
}
|
||||
|
||||
func changeAllContact(allContactBool: Bool) {
|
||||
let preferences = UserDefaults.standard
|
||||
|
||||
allContact = allContactBool
|
||||
preferences.set(allContact, forKey: allContactKey)
|
||||
}
|
||||
|
||||
func updateContacts(
|
||||
sortedLastSearch: [SearchResult],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue