From 62b35c212dc3abca430108254f2ee6fef6d5936e Mon Sep 17 00:00:00 2001 From: David Sinclair Date: Thu, 17 Nov 2022 20:30:47 -0600 Subject: [PATCH] #1747 (marking a feed as read takes you to the wrong feed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The next feed/folder when marking read feature now goes straight to the appropriate feed/folder. - Added a check to avoid looping forever if there aren’t any unreads left. --- clients/ios/Classes/FeedsObjCViewController.m | 104 ++++++++++-------- .../ios/Resources/MainInterface.storyboard | 12 +- 2 files changed, 65 insertions(+), 51 deletions(-) diff --git a/clients/ios/Classes/FeedsObjCViewController.m b/clients/ios/Classes/FeedsObjCViewController.m index 99d06a810..0ccb92c28 100644 --- a/clients/ios/Classes/FeedsObjCViewController.m +++ b/clients/ios/Classes/FeedsObjCViewController.m @@ -1927,44 +1927,52 @@ heightForHeaderInSection:(NSInteger)section { - (void)selectNextFeed:(id)sender { NSArray *indexPaths = [self allIndexPaths]; NSIndexPath *indexPath = self.lastRowAtIndexPath; + NSIndexPath *stopAtIndexPath = indexPath; + BOOL foundNext; - if (indexPath == nil) { - if (self.lastSection < 0) { - indexPath = indexPaths.firstObject; + do { + foundNext = YES; + + if (indexPath == nil) { + if (self.lastSection < 0) { + indexPath = indexPaths.firstObject; + } else { + indexPath = [NSIndexPath indexPathForRow:0 inSection:self.lastSection]; + } + + stopAtIndexPath = indexPath; } else { - indexPath = [NSIndexPath indexPathForRow:0 inSection:self.lastSection]; - } - } else { - NSInteger index = [indexPaths indexOfObject:indexPath]; - - if (index == NSNotFound) { - index = -1; + NSInteger index = [indexPaths indexOfObject:indexPath]; + + if (index == NSNotFound) { + index = -1; + } + + index += 1; + + if (index >= indexPaths.count) { + index = 0; + } + + indexPath = indexPaths[index]; } - index += 1; - - if (index >= indexPaths.count) { - index = 0; + if (sender == nil) { + FeedTableCell *cell = (FeedTableCell *)[self tableView:feedTitlesTable cellForRowAtIndexPath:indexPath]; + NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:indexPath.section]; + id feedId = [[appDelegate.dictFolders objectForKey:folderName] objectAtIndex:indexPath.row]; + NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId]; + BOOL hasUnread = cell.positiveCount > 0 || cell.neutralCount > 0 || cell.negativeCount > 0; + BOOL isInactive = appDelegate.dictInactiveFeeds[feedIdStr] != nil; + + if ([cell.reuseIdentifier isEqualToString:@"BlankCellIdentifier"] || !hasUnread || isInactive) { + foundNext = NO; + } } - - indexPath = indexPaths[index]; - } + } while (!foundNext && ![indexPath isEqual:stopAtIndexPath]); [self.feedTitlesTable selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle]; [self tableView:self.feedTitlesTable didSelectRowAtIndexPath:indexPath]; - - if (sender == nil) { - FeedTableCell *cell = (FeedTableCell *)[self tableView:feedTitlesTable cellForRowAtIndexPath:indexPath]; - NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:indexPath.section]; - id feedId = [[appDelegate.dictFolders objectForKey:folderName] objectAtIndex:indexPath.row]; - NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId]; - BOOL hasUnread = cell.positiveCount > 0 || cell.neutralCount > 0 || cell.negativeCount > 0; - BOOL isInactive = appDelegate.dictInactiveFeeds[feedIdStr] != nil; - - if ([cell.reuseIdentifier isEqualToString:@"BlankCellIdentifier"] || !hasUnread || isInactive) { - [self selectNextFolderOrFeed]; - } - } } - (void)selectPreviousFeed:(id)sender { @@ -1999,12 +2007,28 @@ heightForHeaderInSection:(NSInteger)section { - (void)selectNextFolder:(id)sender { NSInteger section = self.lastSection; + NSInteger stopAtSection = section; + BOOL foundNext; - if (section < self.feedTitlesTable.numberOfSections - 1) { - section += 1; - } else { - section = 0; - } + do { + foundNext = YES; + + if (section < self.feedTitlesTable.numberOfSections - 1) { + section += 1; + } else { + section = 0; + } + + if (sender == nil) { + NSString *folderName = appDelegate.dictFoldersArray[section]; + UnreadCounts *counts = [appDelegate splitUnreadCountForFolder:folderName]; + BOOL hasUnread = counts.ps > 0 || counts.nt > 0; + + if (!hasUnread) { + foundNext = NO; + } + } + } while (!foundNext && section != stopAtSection); [self didSelectSectionHeaderWithTag:section]; @@ -2013,16 +2037,6 @@ heightForHeaderInSection:(NSInteger)section { if ([self.feedTitlesTable numberOfRowsInSection:section] > 0) { [self.feedTitlesTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; } - - if (sender == nil) { - NSString *folderName = appDelegate.dictFoldersArray[section]; - UnreadCounts *counts = [appDelegate splitUnreadCountForFolder:folderName]; - BOOL hasUnread = counts.ps > 0 || counts.nt > 0; - - if (!hasUnread) { - [self selectNextFolderOrFeed]; - } - } } - (void)selectPreviousFolder:(id)sender { diff --git a/clients/ios/Resources/MainInterface.storyboard b/clients/ios/Resources/MainInterface.storyboard index 929e74b13..448712ab5 100644 --- a/clients/ios/Resources/MainInterface.storyboard +++ b/clients/ios/Resources/MainInterface.storyboard @@ -1,9 +1,9 @@ - + - + @@ -432,14 +432,14 @@ - + - - - + + +