Signal-iOS/Signal/src/ViewControllers/DebugSettingsTableViewController.m
Matthew Chen c7426f9343 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
2017-06-15 13:44:30 -04:00

76 lines
1.7 KiB
Objective-C

//
// 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