Add isRegisteredAndReady to TSAccountManager.
This commit is contained in:
parent
70b2280aa7
commit
dcaaff7eac
@ -622,7 +622,7 @@ static NSTimeInterval launchStartedAt;
|
||||
- (void)enableBackgroundRefreshIfNecessary
|
||||
{
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
if (OWS2FAManager.sharedManager.is2FAEnabled && [self.tsAccountManager isRegistered]) {
|
||||
if (OWS2FAManager.sharedManager.is2FAEnabled && [self.tsAccountManager isRegisteredAndReady]) {
|
||||
// Ping server once a day to keep-alive 2FA clients.
|
||||
const NSTimeInterval kBackgroundRefreshInterval = 24 * 60 * 60;
|
||||
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:kBackgroundRefreshInterval];
|
||||
|
||||
@ -259,16 +259,11 @@ NSString *NSStringForBackupImportState(OWSBackupState state)
|
||||
if (!self.isBackupEnabled) {
|
||||
return NO;
|
||||
}
|
||||
if (self.hasPendingRestoreDecision) {
|
||||
// Don't backup while awaiting user decision about
|
||||
// whether to import previous backup.
|
||||
return NO;
|
||||
}
|
||||
if (UIApplication.sharedApplication.applicationState != UIApplicationStateActive) {
|
||||
// Don't start backups when app is in the background.
|
||||
return NO;
|
||||
}
|
||||
if (![self.tsAccountManager isRegistered]) {
|
||||
if (![self.tsAccountManager isRegisteredAndReady]) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
|
||||
@ -208,14 +208,14 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
|
||||
return;
|
||||
}
|
||||
|
||||
if ([TSAccountManager sharedInstance].isRegistered) {
|
||||
if ([TSAccountManager sharedInstance].isRegisteredAndReady) {
|
||||
[self sendSyncContactsMessageIfNecessary];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendConfigurationSyncMessage {
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
if (!self.tsAccountManager.isRegistered) {
|
||||
if (!self.tsAccountManager.isRegisteredAndReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
|
||||
- (void)sendConfigurationSyncMessage_AppReady {
|
||||
DDLogInfo(@"");
|
||||
|
||||
if (![TSAccountManager sharedInstance].isRegistered) {
|
||||
if (![TSAccountManager sharedInstance].isRegisteredAndReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#import "OWSQueues.h"
|
||||
#import "OWSStorage.h"
|
||||
#import "SSKEnvironment.h"
|
||||
#import "TSAccountManager.h"
|
||||
#import "TSDatabaseView.h"
|
||||
#import "TSErrorMessage.h"
|
||||
#import "TSYapDatabaseObject.h"
|
||||
@ -267,6 +268,10 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
||||
selector:@selector(applicationDidEnterBackground:)
|
||||
name:OWSApplicationDidEnterBackgroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(registrationStateDidChange:)
|
||||
name:RegistrationStateDidChangeNotification
|
||||
object:nil];
|
||||
|
||||
// Start processing.
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
@ -292,6 +297,13 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
||||
return SSKEnvironment.shared.messageManager;
|
||||
}
|
||||
|
||||
- (TSAccountManager *)tsAccountManager
|
||||
{
|
||||
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
|
||||
|
||||
return SSKEnvironment.shared.tsAccountManager;
|
||||
}
|
||||
|
||||
#pragma mark - Notifications
|
||||
|
||||
- (void)applicationWillEnterForeground:(NSNotification *)notification
|
||||
@ -304,6 +316,17 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
||||
self.isAppInBackground = YES;
|
||||
}
|
||||
|
||||
- (void)registrationStateDidChange:(NSNotification *)notification
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
if (CurrentAppContext().isMainApp) {
|
||||
[self drainQueue];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - instance methods
|
||||
|
||||
- (dispatch_queue_t)serialQueue
|
||||
@ -335,6 +358,9 @@ NSString *const OWSMessageContentJobFinderExtensionGroup = @"OWSMessageContentJo
|
||||
if (!CurrentAppContext().isMainApp) {
|
||||
return;
|
||||
}
|
||||
if (!self.tsAccountManager.isRegisteredAndReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(self.serialQueue, ^{
|
||||
if (self.isDrainingQueue) {
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#import "OWSQueues.h"
|
||||
#import "OWSStorage.h"
|
||||
#import "SSKEnvironment.h"
|
||||
#import "TSAccountManager.h"
|
||||
#import "TSDatabaseView.h"
|
||||
#import "TSErrorMessage.h"
|
||||
#import "TSYapDatabaseObject.h"
|
||||
@ -254,6 +255,11 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
||||
}
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(registrationStateDidChange:)
|
||||
name:RegistrationStateDidChangeNotification
|
||||
object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -273,6 +279,26 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
||||
return SSKEnvironment.shared.batchMessageProcessor;
|
||||
}
|
||||
|
||||
- (TSAccountManager *)tsAccountManager
|
||||
{
|
||||
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
|
||||
|
||||
return SSKEnvironment.shared.tsAccountManager;
|
||||
}
|
||||
|
||||
#pragma mark - Notifications
|
||||
|
||||
- (void)registrationStateDidChange:(NSNotification *)notification
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
if (CurrentAppContext().isMainApp) {
|
||||
[self drainQueue];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Instance methods
|
||||
|
||||
- (dispatch_queue_t)serialQueue
|
||||
@ -298,6 +324,9 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
|
||||
if (!CurrentAppContext().isMainApp) {
|
||||
return;
|
||||
}
|
||||
if (!self.tsAccountManager.isRegisteredAndReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(self.serialQueue, ^{
|
||||
if (self.isDrainingQueue) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user