Revisit TODOs in the SAE work.

pull/1/head
Matthew Chen 7 years ago
parent ebb778cf52
commit 9c8178653d

@ -554,12 +554,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// and continue cleaning in the background. // and continue cleaning in the background.
[[OWSDisappearingMessagesJob sharedJob] startIfNecessary]; [[OWSDisappearingMessagesJob sharedJob] startIfNecessary];
// TODO remove this once we're sure our app boot process is coherent.
// Currently this happens *before* db registration is complete when
// launching the app directly, but *after* db registration is complete when
// the app is launched in the background, e.g. from a voip notification.
[[OWSProfileManager sharedManager] ensureLocalProfileCached];
// Mark all "attempting out" messages as "unsent", i.e. any messages that were not successfully // Mark all "attempting out" messages as "unsent", i.e. any messages that were not successfully
// sent before the app exited should be marked as failures. // sent before the app exited should be marked as failures.
[[[OWSFailedMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run]; [[[OWSFailedMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];
@ -993,6 +987,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[OWSPreferences setIsRegistered:[TSAccountManager isRegistered]]; [OWSPreferences setIsRegistered:[TSAccountManager isRegistered]];
// TODO: Once "app ready" logic is moved into AppSetup, move this line there.
[[OWSProfileManager sharedManager] ensureLocalProfileCached];
// Note that this does much more than set a flag; // Note that this does much more than set a flag;
// it will also run all deferred blocks. // it will also run all deferred blocks.
[AppReadiness setAppIsReady]; [AppReadiness setAppIsReady];
@ -1013,7 +1010,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self]; [DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self];
[AppVersion.instance appLaunchDidComplete]; [AppVersion.instance mainAppLaunchDidComplete];
[Environment.current.contactsManager loadSignalAccountsFromCache]; [Environment.current.contactsManager loadSignalAccountsFromCache];
@ -1021,8 +1018,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[[OWSMessageReceiver sharedInstance] handleAnyUnprocessedEnvelopesAsync]; [[OWSMessageReceiver sharedInstance] handleAnyUnprocessedEnvelopesAsync];
[[OWSBatchMessageProcessor sharedInstance] handleAnyUnprocessedEnvelopesAsync]; [[OWSBatchMessageProcessor sharedInstance] handleAnyUnprocessedEnvelopesAsync];
[[OWSProfileManager sharedManager] ensureLocalProfileCached];
#ifdef DEBUG #ifdef DEBUG
// A bug in orphan cleanup could be disastrous so let's only // A bug in orphan cleanup could be disastrous so let's only

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
@interface AppVersion : NSObject @interface AppVersion : NSObject
@ -11,10 +11,13 @@
// Unlike lastAppVersion, this property isn't updated until // Unlike lastAppVersion, this property isn't updated until
// appLaunchDidComplete is called. // appLaunchDidComplete is called.
@property (nonatomic, readonly) NSString *lastCompletedLaunchAppVersion; @property (nonatomic, readonly) NSString *lastCompletedLaunchAppVersion;
@property (nonatomic, readonly) NSString *lastCompletedLaunchMainAppVersion;
@property (nonatomic, readonly) NSString *lastCompletedLaunchSAEAppVersion;
+ (instancetype)instance; + (instancetype)instance;
- (void)appLaunchDidComplete; - (void)mainAppLaunchDidComplete;
- (void)saeLaunchDidComplete;
- (BOOL)isFirstLaunch; - (BOOL)isFirstLaunch;

@ -8,6 +8,10 @@
NSString *const kNSUserDefaults_FirstAppVersion = @"kNSUserDefaults_FirstAppVersion"; NSString *const kNSUserDefaults_FirstAppVersion = @"kNSUserDefaults_FirstAppVersion";
NSString *const kNSUserDefaults_LastAppVersion = @"kNSUserDefaults_LastVersion"; NSString *const kNSUserDefaults_LastAppVersion = @"kNSUserDefaults_LastVersion";
NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefaults_LastCompletedLaunchAppVersion"; NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefaults_LastCompletedLaunchAppVersion";
NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion_MainApp
= @"kNSUserDefaults_LastCompletedLaunchAppVersion_MainApp";
NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion_SAE
= @"kNSUserDefaults_LastCompletedLaunchAppVersion_SAE";
@interface AppVersion () @interface AppVersion ()
@ -15,6 +19,8 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
@property (nonatomic) NSString *lastAppVersion; @property (nonatomic) NSString *lastAppVersion;
@property (nonatomic) NSString *currentAppVersion; @property (nonatomic) NSString *currentAppVersion;
@property (nonatomic) NSString *lastCompletedLaunchAppVersion; @property (nonatomic) NSString *lastCompletedLaunchAppVersion;
@property (nonatomic) NSString *lastCompletedLaunchMainAppVersion;
@property (nonatomic) NSString *lastCompletedLaunchSAEAppVersion;
@end @end
@ -44,6 +50,10 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
self.lastAppVersion = [[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastAppVersion]; self.lastAppVersion = [[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastAppVersion];
self.lastCompletedLaunchAppVersion = self.lastCompletedLaunchAppVersion =
[[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastCompletedLaunchAppVersion]; [[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastCompletedLaunchAppVersion];
self.lastCompletedLaunchMainAppVersion =
[[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastCompletedLaunchAppVersion_MainApp];
self.lastCompletedLaunchSAEAppVersion =
[[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastCompletedLaunchAppVersion_SAE];
// Ensure the value for the "first launched version". // Ensure the value for the "first launched version".
if (!self.firstAppVersion) { if (!self.firstAppVersion) {
@ -63,6 +73,8 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]); [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]);
DDLogInfo(@"%@ lastCompletedLaunchAppVersion: %@", self.logTag, self.lastCompletedLaunchAppVersion); DDLogInfo(@"%@ lastCompletedLaunchAppVersion: %@", self.logTag, self.lastCompletedLaunchAppVersion);
DDLogInfo(@"%@ lastCompletedLaunchMainAppVersion: %@", self.logTag, self.lastCompletedLaunchMainAppVersion);
DDLogInfo(@"%@ lastCompletedLaunchSAEAppVersion: %@", self.logTag, self.lastCompletedLaunchSAEAppVersion);
} }
- (void)appLaunchDidComplete - (void)appLaunchDidComplete
@ -77,6 +89,24 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
[[NSUserDefaults appUserDefaults] synchronize]; [[NSUserDefaults appUserDefaults] synchronize];
} }
- (void)mainAppLaunchDidComplete
{
self.lastCompletedLaunchMainAppVersion = self.currentAppVersion;
[[NSUserDefaults appUserDefaults] setObject:self.currentAppVersion
forKey:kNSUserDefaults_LastCompletedLaunchAppVersion_MainApp];
[self appLaunchDidComplete];
}
- (void)saeLaunchDidComplete
{
self.lastCompletedLaunchSAEAppVersion = self.currentAppVersion;
[[NSUserDefaults appUserDefaults] setObject:self.currentAppVersion
forKey:kNSUserDefaults_LastCompletedLaunchAppVersion_SAE];
[self appLaunchDidComplete];
}
- (BOOL)isFirstLaunch - (BOOL)isFirstLaunch
{ {
return self.firstAppVersion != nil; return self.firstAppVersion != nil;

@ -50,8 +50,8 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use DeviceSleepManager in the SAE. // We don't need to use DeviceSleepManager in the SAE.
// TODO: // TODO: Do we need to applySignalAppearence in the SAE?
// [UIUtil applySignalAppearence]; UIUtil.applySignalAppearence()
if CurrentAppContext().isRunningTests { if CurrentAppContext().isRunningTests {
// TODO: Do we need to implement isRunningTests in the SAE context? // TODO: Do we need to implement isRunningTests in the SAE context?
@ -154,12 +154,6 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use OWSDisappearingMessagesJob in the SAE. // We don't need to use OWSDisappearingMessagesJob in the SAE.
// TODO remove this once we're sure our app boot process is coherent.
// Currently this happens *before* db registration is complete when
// launching the app directly, but *after* db registration is complete when
// the app is launched in the background, e.g. from a voip notification.
OWSProfileManager.shared().ensureLocalProfileCached()
// We don't need to use OWSFailedMessagesJob in the SAE. // We don't need to use OWSFailedMessagesJob in the SAE.
// We don't need to use OWSFailedAttachmentDownloadsJob in the SAE. // We don't need to use OWSFailedAttachmentDownloadsJob in the SAE.
@ -172,7 +166,6 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to prod the TSSocketManager in the SAE. // We don't need to prod the TSSocketManager in the SAE.
} }
// TODO: Do we want to move this logic into the notification handler for "SAE will appear".
if TSAccountManager.isRegistered() { if TSAccountManager.isRegistered() {
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return } guard let strongSelf = self else { return }
@ -227,6 +220,9 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
Logger.debug("\(self.logTag) \(#function)") Logger.debug("\(self.logTag) \(#function)")
// TODO: Once "app ready" logic is moved into AppSetup, move this line there.
OWSProfileManager.shared().ensureLocalProfileCached()
// Note that this does much more than set a flag; // Note that this does much more than set a flag;
// it will also run all deferred blocks. // it will also run all deferred blocks.
AppReadiness.setAppIsReady() AppReadiness.setAppIsReady()
@ -241,8 +237,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use DeviceSleepManager in the SAE. // We don't need to use DeviceSleepManager in the SAE.
// TODO: Should we distinguish main app and SAE "completion"? AppVersion.instance().saeLaunchDidComplete()
AppVersion.instance().appLaunchDidComplete()
Environment.current().contactsManager.loadSignalAccountsFromCache() Environment.current().contactsManager.loadSignalAccountsFromCache()

@ -189,7 +189,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isRunningTests - (BOOL)isRunningTests
{ {
// TODO: I don't think we'll need to distinguish this in the SAE. // We don't need to distinguish this in the SAE.
return NO; return NO;
} }

Loading…
Cancel
Save