Revert "oOnly one system contacts fetch at a time."

This reverts commit d84e27f5a5f953fd68dbdf1086a75ffe6aee6720.
pull/1/head
Matthew Chen 6 years ago
parent b767996dba
commit bec5a9f428

@ -146,9 +146,6 @@ public class SystemContactsFetcher: NSObject {
public private(set) var systemContactsHaveBeenRequestedAtLeastOnce = false
private var hasSetupObservation = false
private var isFetching = false
private var hasQueuedFetch = false
override init() {
self.contactStoreAdapter = ContactsFrameworkContactStoreAdaptee()
@ -235,7 +232,6 @@ public class SystemContactsFetcher: NSObject {
@objc
public func fetchOnceIfAlreadyAuthorized() {
SwiftAssertIsOnMainThread(#function)
guard authorizationStatus == .authorized else {
return
}
@ -273,25 +269,11 @@ public class SystemContactsFetcher: NSObject {
Logger.error("background task time ran out contacts fetch completed.")
})
guard !isFetching else {
Logger.info("\(self.TAG) queuing contact fetch; contact fetch already in flight.")
hasQueuedFetch = true
return
}
isFetching = true
// Ensure completion is invoked on main thread.
let completion: (Error?) -> Void = { error in
DispatchMainThreadSafe({
self.isFetching = false
completionParam?(error)
backgroundTask = nil
if self.hasQueuedFetch {
self.hasQueuedFetch = false
self.fetchOnceIfAlreadyAuthorized()
}
})
}

Loading…
Cancel
Save