From c85de5d3dfe43cf7a7a6178f3cb479e81e1849df Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Mon, 26 Nov 2012 15:51:50 -0800 Subject: [PATCH] Fixing long-time bug that crashed the ios app on feed refresh, when a feed had stories but was refreshed to no longer show stories. --- media/ios/Classes/NewsBlurViewController.m | 26 +++++++++++++++++++++- media/ios/NewsBlur_Prefix.pch | 4 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/media/ios/Classes/NewsBlurViewController.m b/media/ios/Classes/NewsBlurViewController.m index 79b76a4a0..fa85905d5 100644 --- a/media/ios/Classes/NewsBlurViewController.m +++ b/media/ios/Classes/NewsBlurViewController.m @@ -1359,18 +1359,42 @@ static const CGFloat kFolderTitleHeight = 28; NSMutableDictionary *updatedDictFeeds = [appDelegate.dictFeeds mutableCopy]; NSDictionary *newFeedCounts = [results objectForKey:@"feeds"]; + NSInteger intelligenceLevel = [appDelegate selectedIntelligence]; for (id feed in newFeedCounts) { NSString *feedIdStr = [NSString stringWithFormat:@"%@", feed]; NSMutableDictionary *newFeed = [[appDelegate.dictFeeds objectForKey:feedIdStr] mutableCopy]; NSMutableDictionary *newFeedCount = [newFeedCounts objectForKey:feed]; if ([newFeed isKindOfClass:[NSDictionary class]]) { - + // Check if a feed goes from visible to hidden, but doesn't disappear. + if ((intelligenceLevel > 0 && + [[newFeed objectForKey:@"ps"] intValue] > 0 && + [[newFeedCount objectForKey:@"ps"] intValue] == 0) || + (intelligenceLevel == 0 && + ([[newFeed objectForKey:@"ps"] intValue] > 0 || [[newFeed objectForKey:@"nt"] intValue] > 0) && + [[newFeedCount objectForKey:@"ps"] intValue] == 0 && + [[newFeedCount objectForKey:@"nt"] intValue] == 0)) { + NSIndexPath *indexPath; + for (int s=0; s < [appDelegate.dictFoldersArray count]; s++) { + NSString *folderName = [appDelegate.dictFoldersArray objectAtIndex:s]; + NSArray *activeFolderFeeds = [self.activeFeedLocations objectForKey:folderName]; + NSArray *originalFolder = [appDelegate.dictFolders objectForKey:folderName]; + for (int l=0; l < [activeFolderFeeds count]; l++) { + if ([[originalFolder objectAtIndex:[[activeFolderFeeds objectAtIndex:l] intValue]] intValue] == [feed intValue]) { + indexPath = [NSIndexPath indexPathForRow:l inSection:s]; + } + } + } + if (indexPath) { + [self.stillVisibleFeeds setObject:indexPath forKey:feedIdStr]; + } + } [newFeed setObject:[newFeedCount objectForKey:@"ng"] forKey:@"ng"]; [newFeed setObject:[newFeedCount objectForKey:@"nt"] forKey:@"nt"]; [newFeed setObject:[newFeedCount objectForKey:@"ps"] forKey:@"ps"]; [updatedDictFeeds setObject:newFeed forKey:feedIdStr]; } + } NSMutableDictionary *updatedDictSocialFeeds = [appDelegate.dictSocialFeeds mutableCopy]; diff --git a/media/ios/NewsBlur_Prefix.pch b/media/ios/NewsBlur_Prefix.pch index eb52457f4..f12b84a6c 100644 --- a/media/ios/NewsBlur_Prefix.pch +++ b/media/ios/NewsBlur_Prefix.pch @@ -15,8 +15,8 @@ // #define BACKGROUND_REFRESH_SECONDS -5 #define BACKGROUND_REFRESH_SECONDS -10*60 -// #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.com"] - #define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"] + #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.com"] +// #define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"] #define NEWSBLUR_LINK_COLOR 0x405BA8 #define NEWSBLUR_HIGHLIGHT_COLOR 0xd2e6fd