Avoid crashing on startup due to database view creation.
* Substitute unread view for unseen view until unseen view is ready. * Register as many views as possible async. * Perform blocking, safe migrations before async registration of views. * Add debug settings view for internal app stats. * Show blocking overlay until async registration of database views is complete. * Convert version migrations to use AppVersions. // FREEBIE
This commit is contained in:
parent
7b47cd8806
commit
c7426f9343
4
Podfile
4
Podfile
|
@ -5,8 +5,8 @@ target 'Signal' do
|
|||
pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git'
|
||||
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
|
||||
#pod 'AxolotlKit', path: '../SignalProtocolKit'
|
||||
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
#pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
#pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu'
|
||||
#pod 'JSQMessagesViewController' path: '../JSQMessagesViewController'
|
||||
pod 'PureLayout'
|
||||
|
|
|
@ -112,7 +112,7 @@ DEPENDENCIES:
|
|||
- JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController.git`, branch `mkirk/position-edit-menu`)
|
||||
- PureLayout
|
||||
- Reachability
|
||||
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
|
||||
- SignalServiceKit (from `../SignalServiceKit`)
|
||||
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
|
@ -122,7 +122,7 @@ EXTERNAL SOURCES:
|
|||
:branch: mkirk/position-edit-menu
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
:path: ../SignalServiceKit
|
||||
SocketRocket:
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
||||
|
@ -133,9 +133,6 @@ CHECKOUT OPTIONS:
|
|||
JSQMessagesViewController:
|
||||
:commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:commit: 96dc0e4fdb3cf8c99a64230814c849ed0968c087
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
SocketRocket:
|
||||
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
@ -161,6 +158,6 @@ SPEC CHECKSUMS:
|
|||
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
|
||||
YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266
|
||||
|
||||
PODFILE CHECKSUM: 89fd7aee1e2b0ca592ecc9dba0389e57b70f959b
|
||||
PODFILE CHECKSUM: 6e5d90a9603eb043b395213fd8a29037d2276a8f
|
||||
|
||||
COCOAPODS: 1.2.1
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
34B3F89C1E8DF3270035BE1A /* BlockListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F89B1E8DF3270035BE1A /* BlockListViewController.m */; };
|
||||
34B3F89F1E8DF5490035BE1A /* OWSTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F89E1E8DF5490035BE1A /* OWSTableViewController.m */; };
|
||||
34B3F8A21E8EA6040035BE1A /* ViewControllerUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8A11E8EA6040035BE1A /* ViewControllerUtils.m */; };
|
||||
34B7F3691EF2DB2E0083AF1C /* DebugSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B7F3681EF2DB2E0083AF1C /* DebugSettingsTableViewController.m */; };
|
||||
34D5CC961EA6AFAD005515DB /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */; };
|
||||
34D5CCA91EAE3D30005515DB /* GroupViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCA81EAE3D30005515DB /* GroupViewHelper.m */; };
|
||||
34D5CCB11EAE7E7F005515DB /* SelectRecipientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */; };
|
||||
|
@ -475,6 +476,8 @@
|
|||
34B3F89E1E8DF5490035BE1A /* OWSTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSTableViewController.m; sourceTree = "<group>"; };
|
||||
34B3F8A01E8EA6040035BE1A /* ViewControllerUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerUtils.h; sourceTree = "<group>"; };
|
||||
34B3F8A11E8EA6040035BE1A /* ViewControllerUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerUtils.m; sourceTree = "<group>"; };
|
||||
34B7F3671EF2DB2E0083AF1C /* DebugSettingsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugSettingsTableViewController.h; sourceTree = "<group>"; };
|
||||
34B7F3681EF2DB2E0083AF1C /* DebugSettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugSettingsTableViewController.m; sourceTree = "<group>"; };
|
||||
34D5CC941EA6AFAD005515DB /* OWSContactsSyncing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactsSyncing.h; sourceTree = "<group>"; };
|
||||
34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = "<group>"; };
|
||||
34D5CC981EA6EB79005515DB /* OWSMessageCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageCollectionViewCell.h; sourceTree = "<group>"; };
|
||||
|
@ -927,6 +930,8 @@
|
|||
3448BFC01EDF0EA7005B2D69 /* ConversationView */,
|
||||
34B3F8401E8DF1700035BE1A /* CountryCodeViewController.h */,
|
||||
34B3F8411E8DF1700035BE1A /* CountryCodeViewController.m */,
|
||||
34B7F3671EF2DB2E0083AF1C /* DebugSettingsTableViewController.h */,
|
||||
34B7F3681EF2DB2E0083AF1C /* DebugSettingsTableViewController.m */,
|
||||
34D8C0221ED3673300188D7C /* DebugUI */,
|
||||
3497DBED1ECE2E4700DB2605 /* DomainFrontingCountryViewController.h */,
|
||||
3497DBEE1ECE2E4700DB2605 /* DomainFrontingCountryViewController.m */,
|
||||
|
@ -2079,6 +2084,7 @@
|
|||
34B3F8791E8DF1700035BE1A /* CountryCodeViewController.m in Sources */,
|
||||
4CE0E3771B954546007210CF /* TSAnimatedAdapter.m in Sources */,
|
||||
4531C9C41DD8E6D800F08304 /* JSQMessagesCollectionViewCell+OWS.m in Sources */,
|
||||
34B7F3691EF2DB2E0083AF1C /* DebugSettingsTableViewController.m in Sources */,
|
||||
4542F0961EBB9E9A00C7EE92 /* Promise+retainUntilComplete.swift in Sources */,
|
||||
4516E3FF1DD2193B00DC4206 /* OWS101ExistingUsersBlockOnIdentityChange.m in Sources */,
|
||||
4505C2BF1E648EA300CEBF41 /* ExperienceUpgrade.swift in Sources */,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#import <SignalServiceKit/OWSIncomingMessageReadObserver.h>
|
||||
#import <SignalServiceKit/OWSMessageSender.h>
|
||||
#import <SignalServiceKit/TSAccountManager.h>
|
||||
#import <SignalServiceKit/TSDatabaseView.h>
|
||||
#import <SignalServiceKit/TSMessagesManager.h>
|
||||
#import <SignalServiceKit/TSPreKeyManager.h>
|
||||
#import <SignalServiceKit/TSSocketManager.h>
|
||||
|
@ -44,7 +45,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@property (nonatomic, retain) UIWindow *screenProtectionWindow;
|
||||
@property (nonatomic) UIWindow *screenProtectionWindow;
|
||||
@property (nonatomic) UIWindow *databaseViewRegistrationOverlay;
|
||||
@property (nonatomic) OWSIncomingMessageReadObserver *incomingMessageReadObserver;
|
||||
@property (nonatomic) OWSStaleNotificationObserver *staleNotificationObserver;
|
||||
@property (nonatomic) OWSContactsSyncing *contactsSyncing;
|
||||
|
@ -188,6 +190,11 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
self.contactsSyncing = [[OWSContactsSyncing alloc] initWithContactsManager:[Environment getCurrent].contactsManager
|
||||
messageSender:[Environment getCurrent].messageSender];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(databaseViewRegistrationComplete)
|
||||
name:kNSNotificationName_DatabaseViewRegistrationComplete
|
||||
object:nil];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -205,7 +212,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
notificationsManager:[Environment getCurrent].notificationsManager];
|
||||
[TextSecureKitEnv setSharedEnv:sharedEnv];
|
||||
|
||||
[[TSStorageManager sharedManager] setupDatabase];
|
||||
[[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{
|
||||
[VersionMigrations runSafeBlockingMigrations];
|
||||
}];
|
||||
|
||||
self.incomingMessageReadObserver =
|
||||
[[OWSIncomingMessageReadObserver alloc] initWithStorageManager:[TSStorageManager sharedManager]
|
||||
|
@ -408,6 +417,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
|
||||
[self removeScreenProtection];
|
||||
|
||||
[self ensureDatabaseViewRegistrationOverlay];
|
||||
|
||||
// Always check prekeys after app launches, and sometimes check on app activation.
|
||||
[TSPreKeyManager checkPreKeysIfNecessary];
|
||||
}
|
||||
|
@ -674,6 +685,74 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
}
|
||||
}
|
||||
|
||||
- (void)databaseViewRegistrationComplete
|
||||
{
|
||||
DDLogInfo(@"databaseViewRegistrationComplete");
|
||||
|
||||
[self ensureDatabaseViewRegistrationOverlay];
|
||||
}
|
||||
|
||||
- (void)ensureDatabaseViewRegistrationOverlay
|
||||
{
|
||||
BOOL shouldShowOverlay = [TSDatabaseView hasPendingViewRegistrations];
|
||||
|
||||
if (!shouldShowOverlay) {
|
||||
if (self.databaseViewRegistrationOverlay && !self.databaseViewRegistrationOverlay.hidden) {
|
||||
DDLogWarn(@"Hiding database view registration overlay.");
|
||||
}
|
||||
self.databaseViewRegistrationOverlay.hidden = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self.databaseViewRegistrationOverlay || self.databaseViewRegistrationOverlay.hidden) {
|
||||
DDLogWarn(@"Showing database view registration overlay.");
|
||||
}
|
||||
|
||||
if (!self.databaseViewRegistrationOverlay) {
|
||||
// Recycle the "screen lock view", but add a label.
|
||||
UIWindow *window = [[UIWindow alloc] initWithFrame:self.window.bounds];
|
||||
window.hidden = YES;
|
||||
window.opaque = YES;
|
||||
window.userInteractionEnabled = NO;
|
||||
window.windowLevel = CGFLOAT_MAX;
|
||||
window.backgroundColor = UIColor.ows_materialBlueColor;
|
||||
window.rootViewController =
|
||||
[[UIStoryboard storyboardWithName:@"Launch Screen" bundle:nil] instantiateInitialViewController];
|
||||
|
||||
BOOL shouldShowUpgradeLabel = NO;
|
||||
NSString *previousVersion = AppVersion.instance.lastAppVersion;
|
||||
// We added a number of database views in v2.13.0.
|
||||
if ([VersionMigrations isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.13.0"]) {
|
||||
shouldShowUpgradeLabel = YES;
|
||||
}
|
||||
if (shouldShowUpgradeLabel) {
|
||||
UIView *rootView = window.rootViewController.view;
|
||||
UIImageView *iconView = nil;
|
||||
for (UIView *subview in rootView.subviews) {
|
||||
if ([subview isKindOfClass:[UIImageView class]]) {
|
||||
iconView = (UIImageView *)subview;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!iconView) {
|
||||
OWSFail(@"Database view registration overlay has unexpected contents.");
|
||||
} else {
|
||||
UILabel *label = [UILabel new];
|
||||
label.text = NSLocalizedString(
|
||||
@"DATABASE_VIEW_OVERLAY_TITLE", @"Indicates that the app is updating its database.");
|
||||
label.font = [UIFont ows_mediumFontWithSize:18.f];
|
||||
label.textColor = [UIColor whiteColor];
|
||||
[rootView addSubview:label];
|
||||
[label autoHCenterInSuperview];
|
||||
[label autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:iconView withOffset:25.f];
|
||||
}
|
||||
}
|
||||
|
||||
self.databaseViewRegistrationOverlay = window;
|
||||
}
|
||||
self.databaseViewRegistrationOverlay.hidden = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
|
|
|
@ -3617,7 +3617,7 @@ typedef enum : NSUInteger {
|
|||
uint64_t lastVisibleTimestamp = self.lastVisibleTimestamp;
|
||||
[self.editingDatabaseConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
NSMutableArray<id<OWSReadTracking>> *interactions = [NSMutableArray new];
|
||||
[[transaction ext:TSUnseenDatabaseViewExtensionName]
|
||||
[[TSDatabaseView unseenDatabaseViewExtension:transaction]
|
||||
enumerateRowsInGroup:thread.uniqueId
|
||||
usingBlock:^(
|
||||
NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSTableViewController.h"
|
||||
|
||||
@interface DebugSettingsTableViewController : OWSTableViewController
|
||||
|
||||
@end
|
|
@ -0,0 +1,75 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DebugSettingsTableViewController.h"
|
||||
#import "UIFont+OWS.h"
|
||||
#import <SignalServiceKit/TSDatabaseView.h>
|
||||
#import <SignalServiceKit/TSStorageManager.h>
|
||||
|
||||
@implementation DebugSettingsTableViewController
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
self.tableViewStyle = UITableViewStylePlain;
|
||||
[super loadView];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self.navigationController.navigationBar setTranslucent:NO];
|
||||
|
||||
self.title = @"Debugging";
|
||||
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
#pragma mark - Table Contents
|
||||
|
||||
- (void)updateTableContents
|
||||
{
|
||||
OWSTableContents *contents = [OWSTableContents new];
|
||||
OWSTableSection *section = [OWSTableSection new];
|
||||
|
||||
__block NSUInteger threadCount;
|
||||
__block NSUInteger messageCount;
|
||||
[TSStorageManager.sharedManager.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
threadCount = [[transaction ext:TSThreadDatabaseViewExtensionName] numberOfItemsInAllGroups];
|
||||
messageCount = [[transaction ext:TSMessageDatabaseViewExtensionName] numberOfItemsInAllGroups];
|
||||
}];
|
||||
|
||||
[section addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %zd", threadCount]]];
|
||||
[section addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Messages: %zd", messageCount]]];
|
||||
|
||||
[contents addSection:section];
|
||||
|
||||
self.contents = contents;
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)tag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)tag
|
||||
{
|
||||
return self.class.tag;
|
||||
}
|
||||
|
||||
@end
|
|
@ -53,10 +53,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
actionBlock:^{
|
||||
[DebugUIMessages sendTextMessages:1000 thread:thread];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Create 1,000 fake messages"
|
||||
[OWSTableItem itemWithTitle:@"Create 1k fake messages"
|
||||
actionBlock:^{
|
||||
[DebugUIMessages sendFakeTextMessage:1000 thread:thread];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Create 10k fake messages"
|
||||
actionBlock:^{
|
||||
[DebugUIMessages sendFakeTextMessage:10 * 1000 thread:thread];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Send text/x-signal-plain"
|
||||
actionBlock:^{
|
||||
[DebugUIMessages sendOversizeTextMessage:thread];
|
||||
|
|
|
@ -68,6 +68,8 @@ typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)();
|
|||
|
||||
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
||||
|
||||
+ (OWSTableItem *)labelItemWithText:(NSString *)text;
|
||||
|
||||
- (nullable UITableViewCell *)customCell;
|
||||
- (NSNumber *)customRowHeight;
|
||||
|
||||
|
|
|
@ -187,6 +187,22 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
|
|||
return item;
|
||||
}
|
||||
|
||||
+ (OWSTableItem *)labelItemWithText:(NSString *)text
|
||||
{
|
||||
OWSAssert(text.length > 0);
|
||||
|
||||
OWSTableItem *item = [OWSTableItem new];
|
||||
item.itemType = OWSTableItemTypeAction;
|
||||
item.customCellBlock = ^{
|
||||
UITableViewCell *cell = [UITableViewCell new];
|
||||
cell.textLabel.text = text;
|
||||
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
|
||||
cell.textLabel.textColor = [UIColor blackColor];
|
||||
return cell;
|
||||
};
|
||||
return item;
|
||||
}
|
||||
|
||||
- (nullable UITableViewCell *)customCell
|
||||
{
|
||||
if (_customCell) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#import "SettingsTableViewController.h"
|
||||
#import "AboutTableViewController.h"
|
||||
#import "AdvancedSettingsTableViewController.h"
|
||||
#import "DebugSettingsTableViewController.h"
|
||||
#import "Environment.h"
|
||||
#import "NotificationSettingsViewController.h"
|
||||
#import "OWSContactsManager.h"
|
||||
|
@ -196,6 +197,13 @@
|
|||
[weakSelf showAbout];
|
||||
}]];
|
||||
|
||||
#ifdef DEBUG
|
||||
[section addItem:[OWSTableItem disclosureItemWithText:@"Debugging"
|
||||
actionBlock:^{
|
||||
[weakSelf showDebugging];
|
||||
}]];
|
||||
#endif
|
||||
|
||||
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
|
||||
UITableViewCell *cell = [UITableViewCell new];
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
|
@ -267,6 +275,12 @@
|
|||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)showDebugging
|
||||
{
|
||||
DebugSettingsTableViewController *vc = [[DebugSettingsTableViewController alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)dismissWasPressed:(id)sender
|
||||
{
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Created by Michael Kirk on 9/28/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -16,6 +17,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
- (void)runAllOutstanding;
|
||||
|
||||
/**
|
||||
* Run any outstanding version migrations that are a) blocking and b) safe
|
||||
* to be run before the environment and storage is completely configured.
|
||||
*
|
||||
* Specifically, these migrations should not depend on or affect the data
|
||||
* of any database view.
|
||||
*/
|
||||
- (void)runSafeBlockingMigrations;
|
||||
|
||||
/**
|
||||
* On new installations, no need to migrate anything.
|
||||
*/
|
||||
|
|
|
@ -42,9 +42,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
}
|
||||
|
||||
- (void)runSafeBlockingMigrations
|
||||
{
|
||||
[self runMigrations:@[
|
||||
[[OWS104CreateRecipientIdentities alloc] initWithStorageManager:self.storageManager],
|
||||
]];
|
||||
}
|
||||
|
||||
- (void)runAllOutstanding
|
||||
{
|
||||
for (OWSDatabaseMigration *migration in self.allMigrations) {
|
||||
[self runMigrations:self.allMigrations];
|
||||
}
|
||||
|
||||
- (void)runMigrations:(NSArray<OWSDatabaseMigration *> *)migrations
|
||||
{
|
||||
OWSAssert(migrations);
|
||||
|
||||
for (OWSDatabaseMigration *migration in migrations) {
|
||||
if ([OWSDatabaseMigration fetchObjectWithUniqueID:migration.uniqueId]) {
|
||||
DDLogDebug(@"%@ Skipping previously run migration: %@", self.tag, migration);
|
||||
} else {
|
||||
|
|
|
@ -52,8 +52,6 @@ extern NSString *const PropertyListPreferencesKeyEnableDebugLog;
|
|||
- (BOOL)hasRegisteredVOIPPush;
|
||||
- (void)setHasRegisteredVOIPPush:(BOOL)enabled;
|
||||
|
||||
+ (nullable NSString *)lastRanVersion;
|
||||
+ (NSString *)setAndGetCurrentVersion;
|
||||
|
||||
- (BOOL)hasDeclinedNoContactsView;
|
||||
- (void)setHasDeclinedNoContactsView:(BOOL)value;
|
||||
|
|
|
@ -16,7 +16,6 @@ NSString *const PropertyListPreferencesKeyEnableDebugLog = @"Debugging Log Enabl
|
|||
NSString *const PropertyListPreferencesKeyNotificationPreviewType = @"Notification Preview Type Key";
|
||||
NSString *const PropertyListPreferencesKeyHasSentAMessage = @"User has sent a message";
|
||||
NSString *const PropertyListPreferencesKeyHasArchivedAMessage = @"User archived a message";
|
||||
NSString *const PropertyListPreferencesKeyLastRunSignalVersion = @"SignalUpdateVersionKey";
|
||||
NSString *const PropertyListPreferencesKeyPlaySoundInForeground = @"NotificationSoundInForeground";
|
||||
NSString *const PropertyListPreferencesKeyHasRegisteredVoipPush = @"VOIPPushEnabled";
|
||||
NSString *const PropertyListPreferencesKeyLastRecordedPushToken = @"LastRecordedPushToken";
|
||||
|
@ -159,20 +158,6 @@ NSString *const PropertyListPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNag
|
|||
[self setValueForKey:PropertyListPreferencesKeyHasArchivedAMessage toValue:@(enabled)];
|
||||
}
|
||||
|
||||
+ (nullable NSString *)lastRanVersion
|
||||
{
|
||||
return [NSUserDefaults.standardUserDefaults objectForKey:PropertyListPreferencesKeyLastRunSignalVersion];
|
||||
}
|
||||
|
||||
+ (NSString *)setAndGetCurrentVersion
|
||||
{
|
||||
NSString *currentVersion =
|
||||
[NSString stringWithFormat:@"%@", NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]];
|
||||
[NSUserDefaults.standardUserDefaults setObject:currentVersion
|
||||
forKey:PropertyListPreferencesKeyLastRunSignalVersion];
|
||||
[NSUserDefaults.standardUserDefaults synchronize];
|
||||
return currentVersion;
|
||||
}
|
||||
|
||||
- (BOOL)hasDeclinedNoContactsView
|
||||
{
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
//
|
||||
// VersionMigrations.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 29/07/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
@ -14,4 +10,10 @@
|
|||
|
||||
+ (void)performUpdateCheck;
|
||||
|
||||
+ (void)runSafeBlockingMigrations;
|
||||
|
||||
+ (BOOL)isVersion:(NSString *)thisVersionString
|
||||
atLeast:(NSString *)openLowerBoundVersionString
|
||||
andLessThan:(NSString *)closedUpperBoundVersionString;
|
||||
|
||||
@end
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#import "SignalKeyingStorage.h"
|
||||
#import "TSAccountManager.h"
|
||||
#import "TSNetworkManager.h"
|
||||
#import <SignalServiceKit/AppVersion.h>
|
||||
#import <SignalServiceKit/OWSOrphanedDataCleaner.h>
|
||||
|
||||
#define NEEDS_TO_REGISTER_PUSH_KEY @"Register For Push"
|
||||
|
@ -34,9 +35,8 @@
|
|||
// upgrade process may depend on Environment.
|
||||
OWSAssert([Environment getCurrent]);
|
||||
|
||||
NSString *previousVersion = PropertyListPreferences.lastRanVersion;
|
||||
NSString *currentVersion =
|
||||
[NSString stringWithFormat:@"%@", NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]];
|
||||
NSString *previousVersion = AppVersion.instance.lastAppVersion;
|
||||
NSString *currentVersion = AppVersion.instance.currentAppVersion;
|
||||
|
||||
DDLogInfo(
|
||||
@"%@ Checking migrations. currentVersion: %@, lastRanVersion: %@", self.tag, currentVersion, previousVersion);
|
||||
|
@ -46,7 +46,6 @@
|
|||
OWSDatabaseMigrationRunner *runner =
|
||||
[[OWSDatabaseMigrationRunner alloc] initWithStorageManager:[TSStorageManager sharedManager]];
|
||||
[runner assumeAllExistingMigrationsRun];
|
||||
[PropertyListPreferences setAndGetCurrentVersion];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -93,7 +92,12 @@
|
|||
}
|
||||
|
||||
[[[OWSDatabaseMigrationRunner alloc] initWithStorageManager:[TSStorageManager sharedManager]] runAllOutstanding];
|
||||
[PropertyListPreferences setAndGetCurrentVersion];
|
||||
}
|
||||
|
||||
+ (void)runSafeBlockingMigrations
|
||||
{
|
||||
[[[OWSDatabaseMigrationRunner alloc] initWithStorageManager:[TSStorageManager sharedManager]]
|
||||
runSafeBlockingMigrations];
|
||||
}
|
||||
|
||||
+ (BOOL)isVersion:(NSString *)thisVersionString
|
||||
|
|
|
@ -123,7 +123,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSMutableArray<TSInvalidIdentityKeyErrorMessage *> *blockingSafetyNumberChanges = [NSMutableArray new];
|
||||
NSMutableArray<TSInteraction *> *nonBlockingSafetyNumberChanges = [NSMutableArray new];
|
||||
// We use different views for performance reasons.
|
||||
[[transaction ext:TSThreadSpecialMessagesDatabaseViewExtensionName]
|
||||
[[TSDatabaseView threadSpecialMessagesDatabaseView:transaction]
|
||||
enumerateRowsInGroup:thread.uniqueId
|
||||
usingBlock:^(
|
||||
NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) {
|
||||
|
@ -160,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
result.firstUnseenInteractionTimestamp = firstUnseenInteractionTimestampParameter;
|
||||
} else {
|
||||
TSInteraction *firstUnseenInteraction =
|
||||
[[transaction ext:TSUnseenDatabaseViewExtensionName] firstObjectInGroup:thread.uniqueId];
|
||||
[[TSDatabaseView unseenDatabaseViewExtension:transaction] firstObjectInGroup:thread.uniqueId];
|
||||
if (firstUnseenInteraction) {
|
||||
result.firstUnseenInteractionTimestamp = @(firstUnseenInteraction.timestampForSorting);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}];
|
||||
|
||||
NSUInteger outgoingMessageCount =
|
||||
[[transaction ext:TSThreadOutgoingMessageDatabaseViewExtensionName] numberOfItemsInGroup:thread.uniqueId];
|
||||
[[TSDatabaseView threadOutgoingMessageDatabaseView:transaction] numberOfItemsInGroup:thread.uniqueId];
|
||||
NSUInteger threadMessageCount =
|
||||
[[transaction ext:TSMessageDatabaseViewExtensionName] numberOfItemsInGroup:thread.uniqueId];
|
||||
|
||||
|
|
|
@ -328,6 +328,9 @@
|
|||
/* Accessibility label for the create group new group button */
|
||||
"CREATE_NEW_GROUP" = "Create new group";
|
||||
|
||||
/* Indicates that the app is updating its database. */
|
||||
"DATABASE_VIEW_OVERLAY_TITLE" = "Updating Database";
|
||||
|
||||
/* {{number of days}} embedded in strings, e.g. 'Alice updated disappearing messages expiration to {{5 days}}'. See other *_TIME_AMOUNT strings */
|
||||
"DAYS_TIME_AMOUNT" = "%u days";
|
||||
|
||||
|
|
Loading…
Reference in New Issue