Force contacts intersection in pull-to-refresh from new thread view.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 3aa90451f1
commit 563753a4cb

@ -127,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssert([NSThread isMainThread]);
[self.contactsViewHelper.contactsManager requestSystemContactsOnce];
[self.contactsViewHelper.contactsManager fetchSystemContactsIfAlreadyAuthorizedAndIgnoreDebounce];
[refreshControl endRefreshing];
}

@ -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

@ -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

@ -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

Loading…
Cancel
Save