Only show archived threads UI if there are archived threads.
This commit is contained in:
parent
6ab48cec97
commit
2fe7596e04
|
@ -70,6 +70,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
|
||||
@property (nonatomic) TSThread *lastThread;
|
||||
|
||||
@property (nonatomic) BOOL hasArchivedThreadsRow;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
@ -461,6 +463,9 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
|
||||
[self checkIfEmptyView];
|
||||
[self applyDefaultBackButton];
|
||||
if ([self updateHasArchivedThreadsRow]) {
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
|
@ -525,6 +530,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
}];
|
||||
}
|
||||
|
||||
[self updateHasArchivedThreadsRow];
|
||||
[self reloadTableViewData];
|
||||
|
||||
[self checkIfEmptyView];
|
||||
|
@ -622,6 +628,18 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
|
||||
#pragma mark - Table View Data Source
|
||||
|
||||
// Returns YES IFF this value changes.
|
||||
- (BOOL)updateHasArchivedThreadsRow
|
||||
{
|
||||
BOOL hasArchivedThreadsRow = (self.homeViewMode == HomeViewMode_Inbox && self.numberOfArchivedThreads > 0);
|
||||
if (self.hasArchivedThreadsRow == hasArchivedThreadsRow) {
|
||||
return NO;
|
||||
}
|
||||
self.hasArchivedThreadsRow = hasArchivedThreadsRow;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return (NSInteger)[self.threadMappings numberOfSections];
|
||||
|
@ -630,7 +648,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
NSInteger result = (NSInteger)[self.threadMappings numberOfItemsInSection:(NSUInteger)section];
|
||||
if (self.homeViewMode == HomeViewMode_Inbox && self.numberOfArchivedThreads > 0) {
|
||||
if (self.hasArchivedThreadsRow) {
|
||||
// Add the "archived conversations" row.
|
||||
result++;
|
||||
}
|
||||
|
@ -1119,6 +1137,11 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
return;
|
||||
}
|
||||
|
||||
if ([self updateHasArchivedThreadsRow]) {
|
||||
[self.tableView reloadData];
|
||||
return;
|
||||
}
|
||||
|
||||
[self.tableView beginUpdates];
|
||||
|
||||
for (YapDatabaseViewSectionChange *sectionChange in sectionChanges) {
|
||||
|
|
Loading…
Reference in New Issue