Merge branch 'charlesmchen/saeTODOs'

pull/1/head
Matthew Chen 7 years ago
commit 6ed5d814f1

@ -554,12 +554,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// and continue cleaning in the background.
[[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
// sent before the app exited should be marked as failures.
[[[OWSFailedMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];
@ -993,6 +987,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[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;
// it will also run all deferred blocks.
[AppReadiness setAppIsReady];
@ -1013,7 +1010,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self];
[AppVersion.instance appLaunchDidComplete];
[AppVersion.instance mainAppLaunchDidComplete];
[Environment.current.contactsManager loadSignalAccountsFromCache];
@ -1021,8 +1018,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[[OWSMessageReceiver sharedInstance] handleAnyUnprocessedEnvelopesAsync];
[[OWSBatchMessageProcessor sharedInstance] handleAnyUnprocessedEnvelopesAsync];
[[OWSProfileManager sharedManager] ensureLocalProfileCached];
#ifdef DEBUG
// A bug in orphan cleanup could be disastrous so let's only

@ -1370,7 +1370,7 @@ const CGFloat OWSMessageCellCornerRadius = 17;
OWSAssert(backupZipPath.length > 0);
OWSBackupImportViewController *backupViewController = [OWSBackupImportViewController new];
// TODO: Add support for restoring password-protected backups.
// There currently isn't any support for restoring password-protected backups.
[backupViewController importBackup:backupZipPath password:nil];
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:backupViewController];

@ -141,7 +141,6 @@ public class ProfileFetcherJob: NSObject {
}
}
// TODO: This was a struct.
@objc
public class SignalServiceProfile: NSObject {
let TAG = "[SignalServiceProfile]"

@ -50,7 +50,6 @@ extern NSString *const StorageIsReadyNotification;
+ (void)resetAllStorage;
// TODO: Deprecate?
- (YapDatabaseConnection *)newDatabaseConnection;
#ifdef DEBUG

@ -263,7 +263,7 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
// Try to reset app by deleting all databases.
//
// TODO: Possibly clean up all app files.
// [OWSStorage deleteDatabaseFiles];
// [OWSStorage deleteDatabaseFiles];
if (![self tryToLoadDatabase]) {
OWSFail(@"%@ Could not load database (second try)", self.logTag);
@ -599,8 +599,8 @@ typedef NSData *_Nullable (^CreateDatabaseMetadataBlock)(void);
if (CurrentAppContext().isMainApp) {
if (CurrentAppContext().isInBackground) {
// TODO: Rather than crash here, we should detect the situation earlier
// and exit gracefully - (in the app delegate?). See the `
// Rather than crash here, we should have already detected the situation earlier
// and exited gracefully (in the app delegate) using isDatabasePasswordAccessible.
// This is a last ditch effort to avoid blowing away the user's database.
[self raiseKeySpecInaccessibleExceptionWithErrorDescription:errorDescription];
}

@ -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
@ -11,10 +11,13 @@
// Unlike lastAppVersion, this property isn't updated until
// appLaunchDidComplete is called.
@property (nonatomic, readonly) NSString *lastCompletedLaunchAppVersion;
@property (nonatomic, readonly) NSString *lastCompletedLaunchMainAppVersion;
@property (nonatomic, readonly) NSString *lastCompletedLaunchSAEAppVersion;
+ (instancetype)instance;
- (void)appLaunchDidComplete;
- (void)mainAppLaunchDidComplete;
- (void)saeLaunchDidComplete;
- (BOOL)isFirstLaunch;

@ -8,6 +8,10 @@
NSString *const kNSUserDefaults_FirstAppVersion = @"kNSUserDefaults_FirstAppVersion";
NSString *const kNSUserDefaults_LastAppVersion = @"kNSUserDefaults_LastVersion";
NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefaults_LastCompletedLaunchAppVersion";
NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion_MainApp
= @"kNSUserDefaults_LastCompletedLaunchAppVersion_MainApp";
NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion_SAE
= @"kNSUserDefaults_LastCompletedLaunchAppVersion_SAE";
@interface AppVersion ()
@ -15,6 +19,8 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
@property (nonatomic) NSString *lastAppVersion;
@property (nonatomic) NSString *currentAppVersion;
@property (nonatomic) NSString *lastCompletedLaunchAppVersion;
@property (nonatomic) NSString *lastCompletedLaunchMainAppVersion;
@property (nonatomic) NSString *lastCompletedLaunchSAEAppVersion;
@end
@ -32,7 +38,6 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
return instance;
}
// TODO: Modify these NSUserDefaults keys for SAE.
- (void)configure {
self.currentAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
@ -44,6 +49,10 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
self.lastAppVersion = [[NSUserDefaults appUserDefaults] objectForKey:kNSUserDefaults_LastAppVersion];
self.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".
if (!self.firstAppVersion) {
@ -63,6 +72,8 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]);
DDLogInfo(@"%@ lastCompletedLaunchAppVersion: %@", self.logTag, self.lastCompletedLaunchAppVersion);
DDLogInfo(@"%@ lastCompletedLaunchMainAppVersion: %@", self.logTag, self.lastCompletedLaunchMainAppVersion);
DDLogInfo(@"%@ lastCompletedLaunchSAEAppVersion: %@", self.logTag, self.lastCompletedLaunchSAEAppVersion);
}
- (void)appLaunchDidComplete
@ -77,6 +88,24 @@ NSString *const kNSUserDefaults_LastCompletedLaunchAppVersion = @"kNSUserDefault
[[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
{
return self.firstAppVersion != nil;

@ -50,8 +50,8 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use DeviceSleepManager in the SAE.
// TODO:
// [UIUtil applySignalAppearence];
// TODO: Do we need to applySignalAppearence in the SAE?
UIUtil.applySignalAppearence()
if CurrentAppContext().isRunningTests {
// 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.
// 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 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.
}
// TODO: Do we want to move this logic into the notification handler for "SAE will appear".
if TSAccountManager.isRegistered() {
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }
@ -227,6 +220,9 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
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;
// it will also run all deferred blocks.
AppReadiness.setAppIsReady()
@ -241,8 +237,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use DeviceSleepManager in the SAE.
// TODO: Should we distinguish main app and SAE "completion"?
AppVersion.instance().appLaunchDidComplete()
AppVersion.instance().saeLaunchDidComplete()
Environment.current().contactsManager.loadSignalAccountsFromCache()

@ -189,7 +189,7 @@ NS_ASSUME_NONNULL_BEGIN
- (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;
}

Loading…
Cancel
Save