Register all database views asynchronously.

This commit is contained in:
Matthew Chen 2018-01-26 15:58:36 -05:00
parent 5cf89a0f3d
commit 100adae245
4 changed files with 10 additions and 8 deletions

View File

@ -401,7 +401,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[self ensureRootViewController];
[AppReadiness.sharedManager runNowOrWhenAppIsReady:^{
[AppReadiness runNowOrWhenAppIsReady:^{
[self handleActivation];
}];
@ -768,7 +768,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[OWSPreferences setIsRegistered:[TSAccountManager isRegistered]];
[AppReadiness.sharedManager setAppIsReady];
[AppReadiness setAppIsReady];
if ([TSAccountManager isRegistered]) {
DDLogInfo(@"localNumber: %@", [TSAccountManager localNumber]);

View File

@ -314,11 +314,6 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
- (BOOL)areAllRegistrationsComplete
{
DDLogInfo(@"%@ areAllRegistrationsComplete: %d %d = %d",
self.logTag,
self.areSyncRegistrationsComplete,
self.areAsyncRegistrationsComplete,
self.areSyncRegistrationsComplete && self.areAsyncRegistrationsComplete);
return self.areSyncRegistrationsComplete && self.areAsyncRegistrationsComplete;
}

View File

@ -10,10 +10,17 @@ typedef void (^AppReadyBlock)(void);
- (instancetype)init NS_UNAVAILABLE;
// This method can be called on any thread.
+ (BOOL)isAppReady;
// This method should only be called on the main thread.
+ (void)setAppIsReady;
// If the app is ready, the block is called immediately;
// otherwise it is called when the app becomes ready.
//
// This method should only be called on the main thread.
// The block will always be called on the main thread.
+ (void)runNowOrWhenAppIsReady:(AppReadyBlock)block;
@end

View File

@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)isAppReady
{
return self.sharedManager.isAppReady;
return [self.sharedManager isAppReady];
}
+ (void)runNowOrWhenAppIsReady:(AppReadyBlock)block