Spin activity indicator until contacts are fetched

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent f4e471e0db
commit 49196f8013

@ -147,9 +147,13 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssert([NSThread isMainThread]);
[self.contactsViewHelper.contactsManager fetchSystemContactsIfAlreadyAuthorizedAndAlwaysNotify];
[refreshControl endRefreshing];
[self.contactsViewHelper.contactsManager
fetchSystemContactsIfAlreadyAuthorizedAndAlwaysNotifyWithCompletion:^(NSError *_Nullable error) {
if (error) {
DDLogError(@"%@ refreshing contacts failed with error: %@", self.logTag, error);
}
[refreshControl endRefreshing];
}];
}
- (void)showContactsPermissionReminder:(BOOL)isVisible

@ -52,9 +52,11 @@ 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)fetchSystemContactsOnceIfAlreadyAuthorized;
// This variant will fetch system contacts if contact access has already been granted,
// but not prompt for contact access. Also, it will always fire a notification.
- (void)fetchSystemContactsIfAlreadyAuthorizedAndAlwaysNotify;
- (void)fetchSystemContactsIfAlreadyAuthorizedAndAlwaysNotifyWithCompletion:
(void (^)(NSError *_Nullable error))completionHandler;
#pragma mark - Util

@ -95,9 +95,10 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
[self.systemContactsFetcher fetchOnceIfAlreadyAuthorized];
}
- (void)fetchSystemContactsIfAlreadyAuthorizedAndAlwaysNotify
- (void)fetchSystemContactsIfAlreadyAuthorizedAndAlwaysNotifyWithCompletion:
(void (^)(NSError *_Nullable error))completionHandler
{
[self.systemContactsFetcher fetchIfAlreadyAuthorizedAndAlwaysNotify];
[self.systemContactsFetcher fetchIfAlreadyAuthorizedAndAlwaysNotifyWithCompletion:completionHandler];
}
- (BOOL)isSystemContactsAuthorized

@ -434,13 +434,13 @@ class SystemContactsFetcher: NSObject {
updateContacts(completion: nil, alwaysNotify: false)
}
public func fetchIfAlreadyAuthorizedAndAlwaysNotify() {
public func fetchIfAlreadyAuthorizedAndAlwaysNotify(completion: ((Error?) -> Void)?) {
AssertIsOnMainThread()
guard authorizationStatus == .authorized else {
return
}
updateContacts(completion: nil, alwaysNotify: true)
updateContacts(completion: completion, alwaysNotify: true)
}
private func updateContacts(completion completionParam: ((Error?) -> Void)?, alwaysNotify: Bool = false) {

Loading…
Cancel
Save