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

- Another tricksy edge case: was picking the wrong feed if viewing Unread with a nested folder within a collapsed folder! Now much smarter about that.
This commit is contained in:
David Sinclair 2022-11-21 11:17:54 -06:00
parent 6a47503ef4
commit 48c1d80284
3 changed files with 34 additions and 9 deletions

View file

@ -1958,19 +1958,24 @@ heightForHeaderInSection:(NSInteger)section {
}
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 isInactive = appDelegate.dictInactiveFeeds[feedIdStr] != nil;
if ([cell.reuseIdentifier isEqualToString:@"BlankCellIdentifier"]) {
if (isInactive || [appDelegate isFolderOrParentCollapsed:folderName]) {
foundNext = NO;
} else {
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;
FeedTableCell *cell = (FeedTableCell *)[self tableView:feedTitlesTable cellForRowAtIndexPath:indexPath];
if (!hasUnread || isInactive) {
if ([cell.reuseIdentifier isEqualToString:@"BlankCellIdentifier"]) {
foundNext = NO;
} else {
BOOL hasUnread = cell.positiveCount > 0 || cell.neutralCount > 0 || cell.negativeCount > 0;
if (!hasUnread) {
foundNext = NO;
}
}
}
}

View file

@ -415,7 +415,6 @@ SFSafariViewControllerDelegate> {
- (UnreadCounts *)splitUnreadCountForFeed:(NSString *)feedId;
- (UnreadCounts *)splitUnreadCountForFolder:(NSString *)folderName;
- (NSDictionary *)markVisibleStoriesRead;
- (BOOL)isFolderCollapsed:(NSString *)folderName;
- (void)markActiveFolderAllRead;
- (void)markFeedAllRead:(id)feedId;
@ -451,6 +450,9 @@ SFSafariViewControllerDelegate> {
+ (int)computeStoryScore:(NSDictionary *)intelligence;
- (NSString *)extractFolderName:(NSString *)folderName;
- (NSString *)extractParentFolderName:(NSString *)folderName;
- (BOOL)hasParentFolder:(NSString *)folderName;
- (BOOL)isFolderCollapsed:(NSString *)folderName;
- (BOOL)isFolderOrParentCollapsed:(NSString *)folderName;
- (NSArray *)parentFoldersForFeed:(NSString *)feedId;
- (NSString *)feedIdWithoutSearchQuery:(NSString *)feedId;
- (NSString *)searchQueryForFeedId:(NSString *)feedId;

View file

@ -2798,6 +2798,20 @@
return !![self.collapsedFolders objectForKey:folderName];
}
- (BOOL)isFolderOrParentCollapsed:(NSString *)folderName {
if ([self isFolderCollapsed:folderName]) {
return YES;
}
if (![self hasParentFolder:folderName]) {
return NO;
}
NSString *parentFolder = [self extractParentFolderName:folderName];
return [self isFolderOrParentCollapsed:parentFolder];
}
#pragma mark - Story Management
- (NSDictionary *)markVisibleStoriesRead {
@ -3342,6 +3356,10 @@
#pragma mark - Feed Management
- (BOOL)hasParentFolder:(NSString *)folderName {
return [folderName containsString:@" ▸ "];
}
- (NSString *)extractParentFolderName:(NSString *)folderName {
if ([folderName containsString:@"Top Level"] ||
[folderName isEqual:@"everything"] ||