Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent eb3569d8f8
commit 7f23dfa258

@ -6,8 +6,8 @@
#import "AppStoreRating.h" #import "AppStoreRating.h"
#import "AppUpdateNag.h" #import "AppUpdateNag.h"
#import "CodeVerificationViewController.h" #import "CodeVerificationViewController.h"
#import "HomeViewController.h"
#import "DebugLogger.h" #import "DebugLogger.h"
#import "HomeViewController.h"
#import "MainAppContext.h" #import "MainAppContext.h"
#import "NotificationsManager.h" #import "NotificationsManager.h"
#import "OWS2FASettingsViewController.h" #import "OWS2FASettingsViewController.h"
@ -156,7 +156,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// This block will be cleared in storageIsReady. // This block will be cleared in storageIsReady.
[DeviceSleepManager.sharedInstance addBlockWithBlockObject:self]; [DeviceSleepManager.sharedInstance addBlockWithBlockObject:self];
[AppSetup setupEnvironment:^{ [AppSetup setupEnvironmentWithCallMessageHandlerBlock:^{
return SignalApp.sharedApp.callMessageHandler; return SignalApp.sharedApp.callMessageHandler;
} }
notificationsProtocolBlock:^{ notificationsProtocolBlock:^{
@ -1086,6 +1086,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[AppVersion.instance mainAppLaunchDidComplete]; [AppVersion.instance mainAppLaunchDidComplete];
[Environment.current.contactsManager loadSignalAccountsFromCache]; [Environment.current.contactsManager loadSignalAccountsFromCache];
[Environment.current.contactsManager startObserving];
// If there were any messages in our local queue which we hadn't yet processed. // If there were any messages in our local queue which we hadn't yet processed.
[[OWSMessageReceiver sharedInstance] handleAnyUnprocessedEnvelopesAsync]; [[OWSMessageReceiver sharedInstance] handleAnyUnprocessedEnvelopesAsync];

@ -13,9 +13,9 @@ typedef id<NotificationsProtocol> _Nonnull (^NotificationsManagerBlock)(void);
// This is _NOT_ a singleton and will be instantiated each time that the SAE is used. // This is _NOT_ a singleton and will be instantiated each time that the SAE is used.
@interface AppSetup : NSObject @interface AppSetup : NSObject
+ (void)setupEnvironment:(CallMessageHandlerBlock)callMessageHandlerBlock + (void)setupEnvironmentWithCallMessageHandlerBlock:(CallMessageHandlerBlock)callMessageHandlerBlock
notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock
migrationCompletion:(dispatch_block_t)migrationCompletion; migrationCompletion:(dispatch_block_t)migrationCompletion;
@end @end

@ -18,9 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
@implementation AppSetup @implementation AppSetup
+ (void)setupEnvironment:(CallMessageHandlerBlock)callMessageHandlerBlock + (void)setupEnvironmentWithCallMessageHandlerBlock:(CallMessageHandlerBlock)callMessageHandlerBlock
notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock
migrationCompletion:(dispatch_block_t)migrationCompletion migrationCompletion:(dispatch_block_t)migrationCompletion
{ {
OWSAssert(callMessageHandlerBlock); OWSAssert(callMessageHandlerBlock);
OWSAssert(notificationsManagerBlock); OWSAssert(notificationsManagerBlock);
@ -51,19 +51,16 @@ NS_ASSUME_NONNULL_BEGIN
[NSKeyedUnarchiver setClass:[OWSUserProfile class] forClassName:[OWSUserProfile collection]]; [NSKeyedUnarchiver setClass:[OWSUserProfile class] forClassName:[OWSUserProfile collection]];
[NSKeyedUnarchiver setClass:[OWSDatabaseMigration class] forClassName:[OWSDatabaseMigration collection]]; [NSKeyedUnarchiver setClass:[OWSDatabaseMigration class] forClassName:[OWSDatabaseMigration collection]];
[OWSStorage setupStorageWithMigrationBlock:^() { [OWSStorage registerExtensionsWithMigrationBlock:^() {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // Don't start database migrations until storage is ready.
// Don't start database migrations until storage is ready. [VersionMigrations performUpdateCheckWithCompletion:^() {
[VersionMigrations performUpdateCheckWithCompletion:^() { OWSAssertIsOnMainThread();
OWSAssertIsOnMainThread();
migrationCompletion(); migrationCompletion();
backgroundTask = nil; backgroundTask = nil;
}]; }];
});
}]; }];
[[Environment current].contactsManager startObserving];
}); });
} }

@ -88,8 +88,10 @@ NS_ASSUME_NONNULL_BEGIN
[self clearBloomFilterCache]; [self clearBloomFilterCache];
} }
[[[OWSDatabaseMigrationRunner alloc] initWithPrimaryStorage:[OWSPrimaryStorage sharedManager]] dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
runAllOutstandingWithCompletion:completion]; [[[OWSDatabaseMigrationRunner alloc] initWithPrimaryStorage:[OWSPrimaryStorage sharedManager]]
runAllOutstandingWithCompletion:completion];
});
} }
+ (BOOL)isVersion:(NSString *)thisVersionString + (BOOL)isVersion:(NSString *)thisVersionString

@ -58,7 +58,7 @@ typedef void (^OWSStorageMigrationBlock)(void);
// This object can be used to filter database notifications. // This object can be used to filter database notifications.
@property (nonatomic, readonly, nullable) id dbNotificationObject; @property (nonatomic, readonly, nullable) id dbNotificationObject;
+ (void)setupStorageWithMigrationBlock:(OWSStorageMigrationBlock)migrationBlock; + (void)registerExtensionsWithMigrationBlock:(OWSStorageMigrationBlock)migrationBlock;
+ (void)resetAllStorage; + (void)resetAllStorage;

@ -325,7 +325,7 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
OWS_ABSTRACT_METHOD(); OWS_ABSTRACT_METHOD();
} }
+ (void)setupStorageWithMigrationBlock:(OWSStorageMigrationBlock)migrationBlock + (void)registerExtensionsWithMigrationBlock:(OWSStorageMigrationBlock)migrationBlock
{ {
OWSAssert(migrationBlock); OWSAssert(migrationBlock);

@ -88,7 +88,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
}.retainUntilComplete() }.retainUntilComplete()
// We shouldn't set up our environment until after we've consulted isReadyForAppExtensions. // We shouldn't set up our environment until after we've consulted isReadyForAppExtensions.
AppSetup.setupEnvironment({ AppSetup.setupEnvironment(callMessageHandlerBlock: {
return NoopCallMessageHandler() return NoopCallMessageHandler()
}, },
notificationsProtocolBlock: { notificationsProtocolBlock: {
@ -268,6 +268,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
AppVersion.instance().saeLaunchDidComplete() AppVersion.instance().saeLaunchDidComplete()
Environment.current().contactsManager.loadSignalAccountsFromCache() Environment.current().contactsManager.loadSignalAccountsFromCache()
Environment.current().contactsManager.startObserving()
ensureRootViewController() ensureRootViewController()

Loading…
Cancel
Save