#1747 (marking a feed as read takes you to the wrong feed)

- 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.
This commit is contained in:
David Sinclair 2022-11-17 20:30:47 -06:00
parent 7da4a86849
commit 62b35c212d
2 changed files with 65 additions and 51 deletions

View file

@ -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 {

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6pv-7g-17r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6pv-7g-17r">
<device id="ipad11_0rounded" orientation="landscape" layout="fullscreen" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -432,14 +432,14 @@
</scene>
</scenes>
<resources>
<image name="all.png" width="19.5" height="12.5"/>
<image name="all.png" width="14" height="13"/>
<image name="big_world.png" width="30.719999313354492" height="30.719999313354492"/>
<image name="drag_icon.png" width="96" height="24"/>
<image name="nav_icn_add.png" width="49.454544067382812" height="64"/>
<image name="nav_icn_settings.png" width="15.359999656677246" height="12.239999771118164"/>
<image name="unread_blue.png" width="49.5" height="12.5"/>
<image name="unread_green.png" width="49" height="12.5"/>
<image name="unread_yellow.png" width="58" height="12.5"/>
<image name="unread_blue.png" width="44" height="13"/>
<image name="unread_green.png" width="43" height="13"/>
<image name="unread_yellow.png" width="51" height="13"/>
<systemColor name="lightTextColor">
<color white="1" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>