From b6264383d35620980a9f7dc80e84545b0635cdc8 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 14 Jul 2017 14:06:19 -0400 Subject: [PATCH] =?UTF-8?q?Add=20possible=20fixes=20for=20the=20=E2=80=98e?= =?UTF-8?q?mpty=20home=20view=E2=80=99=20issue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit // FREEBIE --- .../src/ViewControllers/InboxTableViewCell.h | 2 - .../ViewControllers/SignalsViewController.m | 43 +++++++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Signal/src/ViewControllers/InboxTableViewCell.h b/Signal/src/ViewControllers/InboxTableViewCell.h index 7a1f5737c..c56e286bc 100644 --- a/Signal/src/ViewControllers/InboxTableViewCell.h +++ b/Signal/src/ViewControllers/InboxTableViewCell.h @@ -10,8 +10,6 @@ NS_ASSUME_NONNULL_BEGIN @class OWSContactsManager; @class AvatarImageView; -typedef enum : NSUInteger { kArchiveState = 0, kInboxState = 1 } CellState; - @interface InboxTableViewCell : UITableViewCell @property (nonatomic) IBOutlet UILabel *nameLabel; diff --git a/Signal/src/ViewControllers/SignalsViewController.m b/Signal/src/ViewControllers/SignalsViewController.m index a96ea5ad0..a584f3922 100644 --- a/Signal/src/ViewControllers/SignalsViewController.m +++ b/Signal/src/ViewControllers/SignalsViewController.m @@ -30,6 +30,8 @@ #define CELL_HEIGHT 72.0f +typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; + @interface SignalsViewController () @property (nonatomic) UITableView *tableView; @@ -175,7 +177,7 @@ @"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode."); __weak SignalsViewController *weakSelf = self; archiveReminderView.tapAction = ^{ - [weakSelf selectedInbox]; + [weakSelf showInboxGrouping]; }; [self.view addSubview:archiveReminderView]; [archiveReminderView autoPinWidthToSuperview]; @@ -239,7 +241,7 @@ // Create the database connection. [self uiDatabaseConnection]; - [self selectedInbox]; + [self showInboxGrouping]; self.segmentedControl = [[UISegmentedControl alloc] initWithItems:@[ NSLocalizedString(@"WHISPER_NAV_BAR_TITLE", nil), @@ -349,9 +351,9 @@ - (void)swappedSegmentedControl { if (self.segmentedControl.selectedSegmentIndex == 0) { - [self selectedInbox]; + [self showInboxGrouping]; } else { - [self selectedArchive]; + [self showArchiveGrouping]; } } @@ -423,6 +425,11 @@ return; } + DDLogDebug(@"%@ shouldObserveDBModifications: %d -> %d", + self.tag, + _shouldObserveDBModifications, + shouldObserveDBModifications); + _shouldObserveDBModifications = shouldObserveDBModifications; if (!self.shouldObserveDBModifications) { @@ -793,18 +800,27 @@ #pragma mark - Groupings -- (void)selectedInbox +- (void)showInboxGrouping { - self.segmentedControl.selectedSegmentIndex = 0; self.viewingThreadsIn = kInboxState; - [self changeToGrouping:TSInboxGroup]; } -- (void)selectedArchive +- (void)showArchiveGrouping { - self.segmentedControl.selectedSegmentIndex = 1; self.viewingThreadsIn = kArchiveState; - [self changeToGrouping:TSArchiveGroup]; +} + +- (void)setViewingThreadsIn:(CellState)viewingThreadsIn +{ + BOOL didChange = _viewingThreadsIn != viewingThreadsIn; + _viewingThreadsIn = viewingThreadsIn; + self.segmentedControl.selectedSegmentIndex = (viewingThreadsIn == kInboxState ? 0 : 1); + if (didChange || !self.threadMappings) { + [self changeToGrouping:(viewingThreadsIn == kInboxState ? TSInboxGroup : TSArchiveGroup)]; + } else { + [self checkIfEmptyView]; + [self updateReminderViews]; + } } - (void)changeToGrouping:(NSString *)grouping { @@ -919,13 +935,6 @@ [self checkIfEmptyView]; } -- (void)setViewingThreadsIn:(CellState)viewingThreadsIn -{ - _viewingThreadsIn = viewingThreadsIn; - - [self checkIfEmptyView]; -} - - (void)checkIfEmptyView { [_tableView setHidden:NO]; [_emptyBoxLabel setHidden:NO];