Fix contacts reminder view

We had a guard that prevented 'called at least once' from ever getting set when contacts access was disabled.

// FREEBIE
This commit is contained in:
Michael Kirk 2018-06-22 11:50:24 -06:00
parent 66ebb7b787
commit 9f06163b76
4 changed files with 12 additions and 10 deletions

View File

@ -304,7 +304,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)updateReminderViews
{
self.archiveReminderView.hidden = self.homeViewMode != HomeViewMode_Archive;
self.missingContactsPermissionView.hidden = !self.shouldShowMissingContactsPermissionView;
self.missingContactsPermissionView.hidden = !self.contactsManager.isSystemContactsDenied;
self.deregisteredView.hidden = !TSAccountManager.sharedInstance.isDeregistered;
self.outageView.hidden = !OutageDetection.sharedManager.hasOutage;
}
@ -699,15 +699,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}
- (BOOL)shouldShowMissingContactsPermissionView
{
if (!self.contactsManager.systemContactsHaveBeenRequestedAtLeastOnce) {
return NO;
}
return !self.contactsManager.isSystemContactsAuthorized;
}
#pragma mark - Table View Data Source
// Returns YES IFF this value changes.

View File

@ -41,6 +41,7 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification;
// Must call `requestSystemContactsOnce` before accessing this method
@property (nonatomic, readonly) BOOL isSystemContactsAuthorized;
@property (nonatomic, readonly) BOOL isSystemContactsDenied;
@property (nonatomic, readonly) BOOL systemContactsHaveBeenRequestedAtLeastOnce;
@property (nonatomic, readonly) BOOL supportsContactEditing;

View File

@ -129,6 +129,11 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
return self.systemContactsFetcher.isAuthorized;
}
- (BOOL)isSystemContactsDenied
{
return self.systemContactsFetcher.isDenied;
}
- (BOOL)systemContactsHaveBeenRequestedAtLeastOnce
{
return self.systemContactsFetcher.systemContactsHaveBeenRequestedAtLeastOnce;

View File

@ -170,6 +170,11 @@ public class SystemContactsFetcher: NSObject {
return self.authorizationStatus == .authorized
}
@objc
public var isDenied: Bool {
return self.authorizationStatus == .denied
}
@objc
public private(set) var systemContactsHaveBeenRequestedAtLeastOnce = false
private var hasSetupObservation = false