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

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

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

Loading…
Cancel
Save