Merge branch 'mkirk/contact-perms'

pull/1/head
Michael Kirk 8 years ago
commit af1fb5444a

@ -128,6 +128,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yapDatabaseModified:)
name:YapDatabaseModifiedNotification
@ -490,6 +494,19 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
self.isAppInBackground = YES;
}
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
// It's possible a thread was created while we where in the background. But since we don't honor contact
// requests unless the app is in the foregrond, we must check again here upon becoming active.
if ([TSThread numberOfKeysInCollection] > 0) {
[self.contactsManager requestSystemContactsOnceWithCompletion:^(NSError *_Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self updateReminderViews];
});
}];
}
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
@ -550,7 +567,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
- (BOOL)shouldShowMissingContactsPermissionView
{
if ([TSContactThread numberOfKeysInCollection] == 0) {
if (!self.contactsManager.systemContactsHaveBeenRequestedAtLeastOnce) {
return NO;
}

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

@ -108,6 +108,11 @@ NSString *const kTSStorageManager_lastKnownContactRecipientIds = @"lastKnownCont
return self.systemContactsFetcher.isAuthorized;
}
- (BOOL)systemContactsHaveBeenRequestedAtLeastOnce
{
return self.systemContactsFetcher.systemContactsHaveBeenRequestedAtLeastOnce;
}
- (BOOL)supportsContactEditing
{
return self.systemContactsFetcher.supportsContactEditing;

@ -342,7 +342,7 @@ class SystemContactsFetcher: NSObject {
return self.authorizationStatus == .authorized
}
private var systemContactsHaveBeenRequestedAtLeastOnce = false
private(set) var systemContactsHaveBeenRequestedAtLeastOnce = false
private var hasSetupObservation = false
override init() {

Loading…
Cancel
Save