diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index a31a6ec6f..f3cbcbfcb 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -127,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert([NSThread isMainThread]); - [self.contactsViewHelper.contactsManager requestSystemContactsOnce]; + [self.contactsViewHelper.contactsManager fetchSystemContactsIfAlreadyAuthorizedAndIgnoreDebounce]; [refreshControl endRefreshing]; } diff --git a/Signal/src/contact/OWSContactsManager.h b/Signal/src/contact/OWSContactsManager.h index 8d8e09a7c..505fa70fb 100644 --- a/Signal/src/contact/OWSContactsManager.h +++ b/Signal/src/contact/OWSContactsManager.h @@ -55,6 +55,7 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification; // Ensure's the app has the latest contacts, but won't prompt the user for contact // access if they haven't granted it. - (void)fetchSystemContactsIfAlreadyAuthorized; +- (void)fetchSystemContactsIfAlreadyAuthorizedAndIgnoreDebounce; #pragma mark - Util diff --git a/Signal/src/contact/OWSContactsManager.m b/Signal/src/contact/OWSContactsManager.m index 53669efd0..398b17b3c 100644 --- a/Signal/src/contact/OWSContactsManager.m +++ b/Signal/src/contact/OWSContactsManager.m @@ -80,7 +80,12 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account - (void)fetchSystemContactsIfAlreadyAuthorized { - [self.systemContactsFetcher fetchIfAlreadyAuthorized]; + [self.systemContactsFetcher fetchIfAlreadyAuthorizedWithIgnoreDebounce:NO]; +} + +- (void)fetchSystemContactsIfAlreadyAuthorizedAndIgnoreDebounce +{ + [self.systemContactsFetcher fetchIfAlreadyAuthorizedWithIgnoreDebounce:YES]; } - (BOOL)isSystemContactsAuthorized diff --git a/Signal/src/contact/SystemContactsFetcher.swift b/Signal/src/contact/SystemContactsFetcher.swift index 41408e855..80aac269a 100644 --- a/Signal/src/contact/SystemContactsFetcher.swift +++ b/Signal/src/contact/SystemContactsFetcher.swift @@ -417,16 +417,16 @@ class SystemContactsFetcher: NSObject { } } - public func fetchIfAlreadyAuthorized() { + public func fetchIfAlreadyAuthorized(ignoreDebounce: Bool = false) { AssertIsOnMainThread() guard authorizationStatus == .authorized else { return } - updateContacts(completion: nil) + updateContacts(completion: nil, ignoreDebounce:ignoreDebounce) } - private func updateContacts(completion: ((Error?) -> Void)?) { + private func updateContacts(completion: ((Error?) -> Void)?, ignoreDebounce: Bool = false) { AssertIsOnMainThread() systemContactsHaveBeenRequestedAtLeastOnce = true @@ -457,6 +457,9 @@ class SystemContactsFetcher: NSObject { if self.lastContactUpdateHash != contactsHash { Logger.info("\(self.TAG) contact hash changed. new contactsHash: \(contactsHash)") shouldNotifyDelegate = true + } else if ignoreDebounce { + Logger.info("\(self.TAG) ignoring debounce.") + shouldNotifyDelegate = true } else { // If nothing has changed, only notify delegate (to perform contact intersection) every N hours