Updating feed (and folder) unread counts when scrolling or marking as read on dashboard river.

This commit is contained in:
Samuel Clay 2017-12-15 18:10:04 -08:00
parent ef96f59c2c
commit 864c7697bf
4 changed files with 58 additions and 15 deletions

View file

@ -1767,6 +1767,11 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
[storiesCollection syncStoryAsRead:story];
[self.storyTitlesTable reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:thisRow inSection:0]]
withRowAnimation:UITableViewRowAnimationFade];
if (self.isDashboardModule) {
id feedId = [story objectForKey:@"story_feed_id"];
[appDelegate refreshFeedCount:feedId];
}
}
}

View file

@ -688,7 +688,7 @@
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[masterContainerViewController dismissViewControllerAnimated:NO completion:nil];
self.modalNavigationController.modalPresentationStyle = UIModalPresentationPageSheet;
self.modalNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[masterContainerViewController presentViewController:modalNavigationController animated:YES completion:nil];
} else {
[navigationController presentViewController:modalNavigationController animated:YES completion:nil];
@ -1428,7 +1428,9 @@
}
- (void)refreshFeedCount:(id)feedId {
[feedsViewController fadeFeed:feedId];
// [feedsViewController fadeFeed:feedId];
[feedsViewController redrawFeedCounts:feedId];
[feedsViewController refreshHeaderCounts];
}
- (void)loadRiverFeedDetailView:(FeedDetailViewController *)feedDetailView withFolder:(NSString *)folder {

View file

@ -28,6 +28,7 @@ UIGestureRecognizerDelegate> {
NSMutableDictionary * activeFeedLocations;
NSMutableDictionary *stillVisibleFeeds;
NSMutableDictionary *visibleFolders;
NSMutableDictionary *indexPathsForFeedIds;
BOOL isOffline;
BOOL viewShowingAllFeeds;
@ -116,6 +117,7 @@ UIGestureRecognizerDelegate> {
- (void)resetToolbar;
- (void)layoutHeaderCounts:(UIInterfaceOrientation)orientation;
- (void)refreshHeaderCounts;
- (void)redrawFeedCounts:(id)feedId;
- (void)resizeFontSize;
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender;

View file

@ -314,18 +314,15 @@ static UIFont *userLabelFont;
NSString *feedIdStr = [NSString stringWithFormat:@"%@", feedId];
[self.feedTitlesTable deselectRowAtIndexPath:[self.feedTitlesTable indexPathForSelectedRow]
animated:YES];
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
if (![preferences boolForKey:@"show_feeds_after_being_read"]) {
for (NSIndexPath *indexPath in [self.feedTitlesTable indexPathsForVisibleRows]) {
NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:indexPath.section];
id cellFeedId = [[appDelegate.dictFolders objectForKey:folderName] objectAtIndex:indexPath.row];
if ([feedIdStr isEqualToString:[NSString stringWithFormat:@"%@", cellFeedId]]) {
[self.feedTitlesTable beginUpdates];
[self.feedTitlesTable reloadRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self.feedTitlesTable endUpdates];
break;
}
for (NSIndexPath *indexPath in [self.feedTitlesTable indexPathsForVisibleRows]) {
NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:indexPath.section];
id cellFeedId = [[appDelegate.dictFolders objectForKey:folderName] objectAtIndex:indexPath.row];
if ([feedIdStr isEqualToString:[NSString stringWithFormat:@"%@", cellFeedId]]) {
[self.feedTitlesTable beginUpdates];
[self.feedTitlesTable reloadRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self.feedTitlesTable endUpdates];
break;
}
}
}
@ -749,12 +746,29 @@ static UIFont *userLabelFont;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && finished) {
[appDelegate.dashboardViewController refreshStories];
[self cacheFeedRowLocations];
}
[self loadNotificationStory];
[[NSNotificationCenter defaultCenter] postNotificationName:@"FinishedLoadingFeedsNotification" object:nil];
}
- (void)cacheFeedRowLocations {
indexPathsForFeedIds = [NSMutableDictionary dictionary];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
dispatch_async(queue, ^{
for (NSString *folderName in appDelegate.dictFoldersArray) {
NSInteger section = [appDelegate.dictFoldersArray indexOfObject:folderName];
NSArray *folder = [appDelegate.dictFolders objectForKey:folderName];
for (NSInteger row=0; row < folder.count; row++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
[indexPathsForFeedIds setObject:indexPath forKey:[folder objectAtIndex:row]];
}
}
});
}
- (void)loadOfflineFeeds:(BOOL)failed {
__block __typeof__(self) _self = self;
self.isOffline = YES;
@ -1211,7 +1225,6 @@ static UIFont *userLabelFont;
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (appDelegate.hasNoSites) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return kBlurblogTableViewRowHeight;
@ -2127,6 +2140,27 @@ heightForHeaderInSection:(NSInteger)section {
}
}
- (void)redrawFeedCounts:(id)feedId {
NSIndexPath *indexPath = [indexPathsForFeedIds objectForKey:feedId];
NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:indexPath.section];
BOOL isFolderCollapsed = [appDelegate isFolderCollapsed:folderName];
if (indexPath) {
[self.feedTitlesTable beginUpdates];
if (isFolderCollapsed) {
[appDelegate.folderCountCache removeObjectForKey:folderName];
NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:indexPath.section];
[self.feedTitlesTable reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
} else {
[self.feedTitlesTable reloadRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationNone];
}
[self.feedTitlesTable endUpdates];
}
[self refreshHeaderCounts];
}
- (void)showRefreshNotifier {
self.notifier.style = NBSyncingStyle;
self.notifier.title = @"On its way...";