diff --git a/clients/ios/Classes/FeedDetailViewController.m b/clients/ios/Classes/FeedDetailViewController.m index 85b39b38e..198bcc845 100644 --- a/clients/ios/Classes/FeedDetailViewController.m +++ b/clients/ios/Classes/FeedDetailViewController.m @@ -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]; + } } } diff --git a/clients/ios/Classes/NewsBlurAppDelegate.m b/clients/ios/Classes/NewsBlurAppDelegate.m index d09a990b3..dad43e040 100644 --- a/clients/ios/Classes/NewsBlurAppDelegate.m +++ b/clients/ios/Classes/NewsBlurAppDelegate.m @@ -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 { diff --git a/clients/ios/Classes/NewsBlurViewController.h b/clients/ios/Classes/NewsBlurViewController.h index b5faa18c9..6b5f5ff18 100644 --- a/clients/ios/Classes/NewsBlurViewController.h +++ b/clients/ios/Classes/NewsBlurViewController.h @@ -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; diff --git a/clients/ios/Classes/NewsBlurViewController.m b/clients/ios/Classes/NewsBlurViewController.m index e9a6871b5..99d10ba32 100644 --- a/clients/ios/Classes/NewsBlurViewController.m +++ b/clients/ios/Classes/NewsBlurViewController.m @@ -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...";