forked from mirrors/linphone-iphone
Add searchForContactsWithoutCoreThread function
This commit is contained in:
parent
273c77edbe
commit
2f95e7b4d3
2 changed files with 28 additions and 4 deletions
|
|
@ -88,7 +88,7 @@ final class ContactsManager: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
MagicSearchSingleton.shared.searchForContactsWithoutCoreThread(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||||
|
|
||||||
let store = CNContactStore()
|
let store = CNContactStore()
|
||||||
store.requestAccess(for: .contacts) { (granted, error) in
|
store.requestAccess(for: .contacts) { (granted, error) in
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,8 @@ final class MagicSearchSingleton: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchForContacts(sourceFlags: Int) {
|
func searchForContactsWithoutCoreThread(sourceFlags: Int) {
|
||||||
coreContext.doOnCoreQueue { _ in
|
if self.magicSearch != nil {
|
||||||
var needResetCache = false
|
var needResetCache = false
|
||||||
|
|
||||||
if let oldFilter = self.previousFilter {
|
if let oldFilter = self.previousFilter {
|
||||||
|
|
@ -118,7 +118,6 @@ final class MagicSearchSingleton: ObservableObject {
|
||||||
}
|
}
|
||||||
self.previousFilter = self.currentFilter
|
self.previousFilter = self.currentFilter
|
||||||
|
|
||||||
|
|
||||||
if needResetCache {
|
if needResetCache {
|
||||||
self.magicSearch.resetSearchCache()
|
self.magicSearch.resetSearchCache()
|
||||||
}
|
}
|
||||||
|
|
@ -131,6 +130,31 @@ final class MagicSearchSingleton: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func searchForContacts(sourceFlags: Int) {
|
||||||
|
if self.magicSearch != nil {
|
||||||
|
coreContext.doOnCoreQueue { _ in
|
||||||
|
var needResetCache = false
|
||||||
|
|
||||||
|
if let oldFilter = self.previousFilter {
|
||||||
|
if oldFilter.count > self.currentFilter.count || oldFilter != self.currentFilter {
|
||||||
|
needResetCache = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.previousFilter = self.currentFilter
|
||||||
|
|
||||||
|
if needResetCache {
|
||||||
|
self.magicSearch.resetSearchCache()
|
||||||
|
}
|
||||||
|
|
||||||
|
self.magicSearch.getContactsListAsync(
|
||||||
|
filter: self.currentFilter,
|
||||||
|
domain: self.allContact ? "" : self.domainDefaultAccount,
|
||||||
|
sourceFlags: sourceFlags,
|
||||||
|
aggregation: MagicSearch.Aggregation.Friend)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func searchForSuggestions() {
|
func searchForSuggestions() {
|
||||||
coreContext.doOnCoreQueue { _ in
|
coreContext.doOnCoreQueue { _ in
|
||||||
var needResetCache = false
|
var needResetCache = false
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue