|
|
@ -2,7 +2,7 @@
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "SignalsViewController.h"
|
|
|
|
#import "HomeViewController.h"
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "AppSettingsViewController.h"
|
|
|
|
#import "AppSettingsViewController.h"
|
|
|
|
#import "InboxTableViewCell.h"
|
|
|
|
#import "InboxTableViewCell.h"
|
|
|
@ -34,7 +34,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
|
|
|
|
|
|
|
|
@interface SignalsViewController () <UITableViewDelegate, UITableViewDataSource, UIViewControllerPreviewingDelegate>
|
|
|
|
@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, UIViewControllerPreviewingDelegate>
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) UITableView *tableView;
|
|
|
|
@property (nonatomic) UITableView *tableView;
|
|
|
|
@property (nonatomic) UILabel *emptyBoxLabel;
|
|
|
|
@property (nonatomic) UILabel *emptyBoxLabel;
|
|
|
@ -74,7 +74,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
@implementation SignalsViewController
|
|
|
|
@implementation HomeViewController
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Init
|
|
|
|
#pragma mark - Init
|
|
|
|
|
|
|
|
|
|
|
@ -169,7 +169,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Remove this.
|
|
|
|
// TODO: Remove this.
|
|
|
|
[[Environment getCurrent] setSignalsViewController:self];
|
|
|
|
[[Environment getCurrent] setHomeViewController:self];
|
|
|
|
|
|
|
|
|
|
|
|
self.navigationItem.rightBarButtonItem =
|
|
|
|
self.navigationItem.rightBarButtonItem =
|
|
|
|
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
|
|
|
|
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
|
|
|
@ -179,7 +179,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
ReminderView *archiveReminderView = [ReminderView new];
|
|
|
|
ReminderView *archiveReminderView = [ReminderView new];
|
|
|
|
archiveReminderView.text = NSLocalizedString(
|
|
|
|
archiveReminderView.text = NSLocalizedString(
|
|
|
|
@"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode.");
|
|
|
|
@"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode.");
|
|
|
|
__weak SignalsViewController *weakSelf = self;
|
|
|
|
__weak HomeViewController *weakSelf = self;
|
|
|
|
archiveReminderView.tapAction = ^{
|
|
|
|
archiveReminderView.tapAction = ^{
|
|
|
|
[weakSelf showInboxGrouping];
|
|
|
|
[weakSelf showInboxGrouping];
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -236,7 +236,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
[self.view layoutSubviews];
|
|
|
|
[self.view layoutSubviews];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
- (void)viewDidLoad
|
|
|
|
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
|
|
|
[super viewDidLoad];
|
|
|
|
[self.navigationController.navigationBar setTranslucent:NO];
|
|
|
|
[self.navigationController.navigationBar setTranslucent:NO];
|
|
|
|
|
|
|
|
|
|
|
@ -263,18 +264,19 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
UINavigationItem *navigationItem = self.navigationItem;
|
|
|
|
UINavigationItem *navigationItem = self.navigationItem;
|
|
|
|
navigationItem.titleView = self.segmentedControl;
|
|
|
|
navigationItem.titleView = self.segmentedControl;
|
|
|
|
[self.segmentedControl setSelectedSegmentIndex:0];
|
|
|
|
[self.segmentedControl setSelectedSegmentIndex:0];
|
|
|
|
navigationItem.leftBarButtonItem.accessibilityLabel = NSLocalizedString(
|
|
|
|
navigationItem.leftBarButtonItem.accessibilityLabel
|
|
|
|
@"SETTINGS_BUTTON_ACCESSIBILITY", @"Accessibility hint for the settings button");
|
|
|
|
= NSLocalizedString(@"SETTINGS_BUTTON_ACCESSIBILITY", @"Accessibility hint for the settings button");
|
|
|
|
|
|
|
|
|
|
|
|
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)] &&
|
|
|
|
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]
|
|
|
|
(self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) {
|
|
|
|
&& (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) {
|
|
|
|
[self registerForPreviewingWithDelegate:self sourceView:self.tableView];
|
|
|
|
[self registerForPreviewingWithDelegate:self sourceView:self.tableView];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[self updateBarButtonItems];
|
|
|
|
[self updateBarButtonItems];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)updateBarButtonItems {
|
|
|
|
- (void)updateBarButtonItems
|
|
|
|
|
|
|
|
{
|
|
|
|
const CGFloat kBarButtonSize = 44;
|
|
|
|
const CGFloat kBarButtonSize = 44;
|
|
|
|
// We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of
|
|
|
|
// We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of
|
|
|
|
// UIBarButtonItem in order to ensure that these buttons are spaced tightly.
|
|
|
|
// UIBarButtonItem in order to ensure that these buttons are spaced tightly.
|
|
|
@ -309,14 +311,16 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
|
|
|
|
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)settingsButtonPressed:(id)sender {
|
|
|
|
- (void)settingsButtonPressed:(id)sender
|
|
|
|
|
|
|
|
{
|
|
|
|
AppSettingsViewController *vc = [AppSettingsViewController new];
|
|
|
|
AppSettingsViewController *vc = [AppSettingsViewController new];
|
|
|
|
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:vc];
|
|
|
|
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:vc];
|
|
|
|
[self presentViewController:navigationController animated:YES completion:nil];
|
|
|
|
[self presentViewController:navigationController animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
|
|
|
|
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
|
|
|
|
viewControllerForLocation:(CGPoint)location {
|
|
|
|
viewControllerForLocation:(CGPoint)location
|
|
|
|
|
|
|
|
{
|
|
|
|
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
|
|
|
|
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
|
|
|
|
|
|
|
|
|
|
|
|
if (indexPath) {
|
|
|
|
if (indexPath) {
|
|
|
@ -335,7 +339,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
|
|
|
|
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
|
|
|
|
commitViewController:(UIViewController *)viewControllerToCommit {
|
|
|
|
commitViewController:(UIViewController *)viewControllerToCommit
|
|
|
|
|
|
|
|
{
|
|
|
|
MessagesViewController *vc = (MessagesViewController *)viewControllerToCommit;
|
|
|
|
MessagesViewController *vc = (MessagesViewController *)viewControllerToCommit;
|
|
|
|
[vc popped];
|
|
|
|
[vc popped];
|
|
|
|
|
|
|
|
|
|
|
@ -361,7 +366,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)swappedSegmentedControl {
|
|
|
|
- (void)swappedSegmentedControl
|
|
|
|
|
|
|
|
{
|
|
|
|
if (self.segmentedControl.selectedSegmentIndex == 0) {
|
|
|
|
if (self.segmentedControl.selectedSegmentIndex == 0) {
|
|
|
|
[self showInboxGrouping];
|
|
|
|
[self showInboxGrouping];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -369,7 +375,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
if ([TSThread numberOfKeysInCollection] > 0) {
|
|
|
|
if ([TSThread numberOfKeysInCollection] > 0) {
|
|
|
|
[self.contactsManager requestSystemContactsOnceWithCompletion:^(NSError *_Nullable error) {
|
|
|
|
[self.contactsManager requestSystemContactsOnceWithCompletion:^(NSError *_Nullable error) {
|
|
|
@ -482,7 +489,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
self.isAppInBackground = YES;
|
|
|
|
self.isAppInBackground = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
|
|
|
|
|
|
{
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
|
|
|
|
|
|
|
if (self.newlyRegisteredUser) {
|
|
|
|
if (self.newlyRegisteredUser) {
|
|
|
@ -528,7 +536,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
NSArray<ExperienceUpgrade *> *unseenUpgrades = [self unseenUpgradeExperiences];
|
|
|
|
NSArray<ExperienceUpgrade *> *unseenUpgrades = [self unseenUpgradeExperiences];
|
|
|
|
|
|
|
|
|
|
|
|
if (unseenUpgrades.count > 0) {
|
|
|
|
if (unseenUpgrades.count > 0) {
|
|
|
|
ExperienceUpgradesPageViewController *experienceUpgradeViewController = [[ExperienceUpgradesPageViewController alloc] initWithExperienceUpgrades:unseenUpgrades];
|
|
|
|
ExperienceUpgradesPageViewController *experienceUpgradeViewController =
|
|
|
|
|
|
|
|
[[ExperienceUpgradesPageViewController alloc] initWithExperienceUpgrades:unseenUpgrades];
|
|
|
|
[self presentViewController:experienceUpgradeViewController
|
|
|
|
[self presentViewController:experienceUpgradeViewController
|
|
|
|
animated:YES
|
|
|
|
animated:YES
|
|
|
|
completion:^{
|
|
|
|
completion:^{
|
|
|
@ -541,7 +550,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
self.hasBeenPresented = YES;
|
|
|
|
self.hasBeenPresented = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tableViewSetUp {
|
|
|
|
- (void)tableViewSetUp
|
|
|
|
|
|
|
|
{
|
|
|
|
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -561,7 +571,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
return (NSInteger)[self.threadMappings numberOfSections];
|
|
|
|
return (NSInteger)[self.threadMappings numberOfSections];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
|
|
|
|
|
|
{
|
|
|
|
return (NSInteger)[self.threadMappings numberOfItemsInSection:(NSUInteger)section];
|
|
|
|
return (NSInteger)[self.threadMappings numberOfItemsInSection:(NSUInteger)section];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -582,7 +593,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
return cell;
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (TSThread *)threadForIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (TSThread *)threadForIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
__block TSThread *thread = nil;
|
|
|
|
__block TSThread *thread = nil;
|
|
|
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
thread = [[transaction extension:TSThreadDatabaseViewExtensionName] objectAtIndexPath:indexPath
|
|
|
|
thread = [[transaction extension:TSThreadDatabaseViewExtensionName] objectAtIndexPath:indexPath
|
|
|
@ -592,7 +604,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
return thread;
|
|
|
|
return thread;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
return InboxTableViewCell.rowHeight;
|
|
|
|
return InboxTableViewCell.rowHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -600,12 +613,14 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView
|
|
|
|
- (void)tableView:(UITableView *)tableView
|
|
|
|
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
|
|
|
|
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
|
|
|
|
forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
forRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
UITableViewRowAction *deleteAction =
|
|
|
|
UITableViewRowAction *deleteAction =
|
|
|
|
[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
|
|
|
|
[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
|
|
|
|
title:NSLocalizedString(@"TXT_DELETE_TITLE", nil)
|
|
|
|
title:NSLocalizedString(@"TXT_DELETE_TITLE", nil)
|
|
|
@ -617,7 +632,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
if (self.viewingThreadsIn == kInboxState) {
|
|
|
|
if (self.viewingThreadsIn == kInboxState) {
|
|
|
|
archiveAction = [UITableViewRowAction
|
|
|
|
archiveAction = [UITableViewRowAction
|
|
|
|
rowActionWithStyle:UITableViewRowActionStyleNormal
|
|
|
|
rowActionWithStyle:UITableViewRowActionStyleNormal
|
|
|
|
title:NSLocalizedString(@"ARCHIVE_ACTION", @"Pressing this button moves a thread from the inbox to the archive")
|
|
|
|
title:NSLocalizedString(@"ARCHIVE_ACTION",
|
|
|
|
|
|
|
|
@"Pressing this button moves a thread from the inbox to the archive")
|
|
|
|
handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull tappedIndexPath) {
|
|
|
|
handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull tappedIndexPath) {
|
|
|
|
[self archiveIndexPath:tappedIndexPath];
|
|
|
|
[self archiveIndexPath:tappedIndexPath];
|
|
|
|
[Environment.preferences setHasArchivedAMessage:YES];
|
|
|
|
[Environment.preferences setHasArchivedAMessage:YES];
|
|
|
@ -626,7 +642,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
archiveAction = [UITableViewRowAction
|
|
|
|
archiveAction = [UITableViewRowAction
|
|
|
|
rowActionWithStyle:UITableViewRowActionStyleNormal
|
|
|
|
rowActionWithStyle:UITableViewRowActionStyleNormal
|
|
|
|
title:NSLocalizedString(@"UNARCHIVE_ACTION", @"Pressing this button moves an archived thread from the archive back to the inbox")
|
|
|
|
title:NSLocalizedString(@"UNARCHIVE_ACTION",
|
|
|
|
|
|
|
|
@"Pressing this button moves an archived thread from the archive back to the inbox")
|
|
|
|
handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull tappedIndexPath) {
|
|
|
|
handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull tappedIndexPath) {
|
|
|
|
[self archiveIndexPath:tappedIndexPath];
|
|
|
|
[self archiveIndexPath:tappedIndexPath];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
@ -636,13 +653,15 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
return @[ deleteAction, archiveAction ];
|
|
|
|
return @[ deleteAction, archiveAction ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - HomeFeedTableViewCellDelegate
|
|
|
|
#pragma mark - HomeFeedTableViewCellDelegate
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tableViewCellTappedDelete:(NSIndexPath *)indexPath {
|
|
|
|
- (void)tableViewCellTappedDelete:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
|
|
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
|
|
|
if ([thread isKindOfClass:[TSGroupThread class]]) {
|
|
|
|
if ([thread isKindOfClass:[TSGroupThread class]]) {
|
|
|
|
|
|
|
|
|
|
|
@ -683,7 +702,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)deleteThread:(TSThread *)thread {
|
|
|
|
- (void)deleteThread:(TSThread *)thread
|
|
|
|
|
|
|
|
{
|
|
|
|
[self.editingDbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
[self.editingDbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
[thread removeWithTransaction:transaction];
|
|
|
|
[thread removeWithTransaction:transaction];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
@ -692,7 +712,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
[self checkIfEmptyView];
|
|
|
|
[self checkIfEmptyView];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)archiveIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (void)archiveIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
|
|
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
|
|
|
|
|
|
|
|
|
|
|
BOOL viewingThreadsIn = self.viewingThreadsIn;
|
|
|
|
BOOL viewingThreadsIn = self.viewingThreadsIn;
|
|
|
@ -719,7 +740,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
[_segmentedControl reloadInputViews];
|
|
|
|
[_segmentedControl reloadInputViews];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
|
|
|
TSThread *thread = [self threadForIndexPath:indexPath];
|
|
|
|
[self presentThread:thread keyboardOnViewAppearing:NO callOnViewAppearing:NO];
|
|
|
|
[self presentThread:thread keyboardOnViewAppearing:NO callOnViewAppearing:NO];
|
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
@ -736,8 +758,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
|
|
|
|
|
|
|
|
// We do this synchronously if we're already on the main thread.
|
|
|
|
// We do this synchronously if we're already on the main thread.
|
|
|
|
DispatchMainThreadSafe(^{
|
|
|
|
DispatchMainThreadSafe(^{
|
|
|
|
MessagesViewController *mvc = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController"
|
|
|
|
MessagesViewController *mvc =
|
|
|
|
bundle:nil];
|
|
|
|
[[MessagesViewController alloc] initWithNibName:@"MessagesViewController" bundle:nil];
|
|
|
|
[mvc configureForThread:thread
|
|
|
|
[mvc configureForThread:thread
|
|
|
|
keyboardOnViewAppearing:keyboardOnViewAppearing
|
|
|
|
keyboardOnViewAppearing:keyboardOnViewAppearing
|
|
|
|
callOnViewAppearing:callOnViewAppearing];
|
|
|
|
callOnViewAppearing:callOnViewAppearing];
|
|
|
@ -865,7 +887,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark Database delegates
|
|
|
|
#pragma mark Database delegates
|
|
|
|
|
|
|
|
|
|
|
|
- (YapDatabaseConnection *)uiDatabaseConnection {
|
|
|
|
- (YapDatabaseConnection *)uiDatabaseConnection
|
|
|
|
|
|
|
|
{
|
|
|
|
NSAssert([NSThread isMainThread], @"Must access uiDatabaseConnection on main thread!");
|
|
|
|
NSAssert([NSThread isMainThread], @"Must access uiDatabaseConnection on main thread!");
|
|
|
|
if (!_uiDatabaseConnection) {
|
|
|
|
if (!_uiDatabaseConnection) {
|
|
|
|
YapDatabase *database = TSStorageManager.sharedManager.database;
|
|
|
|
YapDatabase *database = TSStorageManager.sharedManager.database;
|
|
|
@ -875,7 +898,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
return _uiDatabaseConnection;
|
|
|
|
return _uiDatabaseConnection;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)yapDatabaseModified:(NSNotification *)notification {
|
|
|
|
- (void)yapDatabaseModified:(NSNotification *)notification
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!self.shouldObserveDBModifications) {
|
|
|
|
if (!self.shouldObserveDBModifications) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -964,7 +988,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
[self.tableView endUpdates];
|
|
|
|
[self.tableView endUpdates];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)checkIfEmptyView {
|
|
|
|
- (void)checkIfEmptyView
|
|
|
|
|
|
|
|
{
|
|
|
|
[_tableView setHidden:NO];
|
|
|
|
[_tableView setHidden:NO];
|
|
|
|
[_emptyBoxLabel setHidden:NO];
|
|
|
|
[_emptyBoxLabel setHidden:NO];
|
|
|
|
if (self.viewingThreadsIn == kInboxState && [self.threadMappings numberOfItemsInGroup:TSInboxGroup] == 0) {
|
|
|
|
if (self.viewingThreadsIn == kInboxState && [self.threadMappings numberOfItemsInGroup:TSInboxGroup] == 0) {
|
|
|
@ -979,7 +1004,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setEmptyBoxText {
|
|
|
|
- (void)setEmptyBoxText
|
|
|
|
|
|
|
|
{
|
|
|
|
_emptyBoxLabel.textColor = [UIColor grayColor];
|
|
|
|
_emptyBoxLabel.textColor = [UIColor grayColor];
|
|
|
|
_emptyBoxLabel.font = [UIFont ows_regularFontWithSize:18.f];
|
|
|
|
_emptyBoxLabel.font = [UIFont ows_regularFontWithSize:18.f];
|
|
|
|
_emptyBoxLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
_emptyBoxLabel.textAlignment = NSTextAlignmentCenter;
|