mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Fixing a long-standing iPhone bug: returning to the app meant losing the position of the current feed. Now reading stories will correctly update the feed, even if it is in multiple folders. Progress!
This commit is contained in:
parent
81f3f4f05a
commit
90f2ee3327
4 changed files with 47 additions and 24 deletions
|
@ -36,7 +36,6 @@
|
||||||
int originalStoryCount;
|
int originalStoryCount;
|
||||||
NSInteger selectedIntelligence;
|
NSInteger selectedIntelligence;
|
||||||
NSMutableArray * recentlyReadStories;
|
NSMutableArray * recentlyReadStories;
|
||||||
NSIndexPath * activeFeedIndexPath;
|
|
||||||
NSMutableArray * readStories;
|
NSMutableArray * readStories;
|
||||||
|
|
||||||
NSDictionary * dictFolders;
|
NSDictionary * dictFolders;
|
||||||
|
@ -64,7 +63,6 @@
|
||||||
@property (readwrite) int originalStoryCount;
|
@property (readwrite) int originalStoryCount;
|
||||||
@property (readwrite) NSInteger selectedIntelligence;
|
@property (readwrite) NSInteger selectedIntelligence;
|
||||||
@property (readwrite, retain) NSMutableArray * recentlyReadStories;
|
@property (readwrite, retain) NSMutableArray * recentlyReadStories;
|
||||||
@property (readwrite, retain) NSIndexPath * activeFeedIndexPath;
|
|
||||||
@property (readwrite, retain) NSMutableArray * readStories;
|
@property (readwrite, retain) NSMutableArray * readStories;
|
||||||
|
|
||||||
@property (nonatomic, retain) NSDictionary *dictFolders;
|
@property (nonatomic, retain) NSDictionary *dictFolders;
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
@synthesize selectedIntelligence;
|
@synthesize selectedIntelligence;
|
||||||
@synthesize activeOriginalStoryURL;
|
@synthesize activeOriginalStoryURL;
|
||||||
@synthesize recentlyReadStories;
|
@synthesize recentlyReadStories;
|
||||||
@synthesize activeFeedIndexPath;
|
|
||||||
@synthesize readStories;
|
@synthesize readStories;
|
||||||
|
|
||||||
@synthesize dictFolders;
|
@synthesize dictFolders;
|
||||||
|
@ -80,7 +79,6 @@
|
||||||
[activeStory release];
|
[activeStory release];
|
||||||
[activeOriginalStoryURL release];
|
[activeOriginalStoryURL release];
|
||||||
[recentlyReadStories release];
|
[recentlyReadStories release];
|
||||||
[activeFeedIndexPath release];
|
|
||||||
[readStories release];
|
[readStories release];
|
||||||
|
|
||||||
[dictFolders release];
|
[dictFolders release];
|
||||||
|
@ -304,29 +302,39 @@
|
||||||
if (activeLocation == -1) {
|
if (activeLocation == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
id feedId = [self.activeFeed objectForKey:@"id"];
|
||||||
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId];
|
||||||
int activeIndex = [[activeFeedStoryLocations objectAtIndex:activeLocation] intValue];
|
int activeIndex = [[activeFeedStoryLocations objectAtIndex:activeLocation] intValue];
|
||||||
|
NSDictionary *feed = [self.dictFeeds objectForKey:feedIdStr];
|
||||||
NSDictionary *story = [activeFeedStories objectAtIndex:activeIndex];
|
NSDictionary *story = [activeFeedStories objectAtIndex:activeIndex];
|
||||||
|
|
||||||
[story setValue:[NSNumber numberWithInt:1] forKey:@"read_status"];
|
[story setValue:[NSNumber numberWithInt:1] forKey:@"read_status"];
|
||||||
[self.recentlyReadStories addObject:[NSNumber numberWithInt:activeLocation]];
|
[self.recentlyReadStories addObject:[NSNumber numberWithInt:activeLocation]];
|
||||||
int score = [NewsBlurAppDelegate computeStoryScore:[story objectForKey:@"intelligence"]];
|
int score = [NewsBlurAppDelegate computeStoryScore:[story objectForKey:@"intelligence"]];
|
||||||
if (score > 0) {
|
if (score > 0) {
|
||||||
int unreads = MAX(0, [[activeFeed objectForKey:@"ps"] intValue] - 1);
|
int unreads = MAX(0, [[feed objectForKey:@"ps"] intValue] - 1);
|
||||||
[self.activeFeed setValue:[NSNumber numberWithInt:unreads] forKey:@"ps"];
|
[feed setValue:[NSNumber numberWithInt:unreads] forKey:@"ps"];
|
||||||
} else if (score == 0) {
|
} else if (score == 0) {
|
||||||
int unreads = MAX(0, [[activeFeed objectForKey:@"nt"] intValue] - 1);
|
int unreads = MAX(0, [[feed objectForKey:@"nt"] intValue] - 1);
|
||||||
[self.activeFeed setValue:[NSNumber numberWithInt:unreads] forKey:@"nt"];
|
[feed setValue:[NSNumber numberWithInt:unreads] forKey:@"nt"];
|
||||||
} else if (score < 0) {
|
} else if (score < 0) {
|
||||||
int unreads = MAX(0, [[activeFeed objectForKey:@"ng"] intValue] - 1);
|
int unreads = MAX(0, [[feed objectForKey:@"ng"] intValue] - 1);
|
||||||
[self.activeFeed setValue:[NSNumber numberWithInt:unreads] forKey:@"ng"];
|
[feed setValue:[NSNumber numberWithInt:unreads] forKey:@"ng"];
|
||||||
}
|
}
|
||||||
|
[self.dictFeeds setValue:feed forKey:feedIdStr];
|
||||||
|
|
||||||
// NSLog(@"Marked read %d-%d: %@: %d", activeIndex, activeLocation, self.recentlyReadStories, score);
|
// NSLog(@"Marked read %d-%d: %@: %d", activeIndex, activeLocation, self.recentlyReadStories, score);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)markActiveFeedAllRead {
|
- (void)markActiveFeedAllRead {
|
||||||
[self.activeFeed setValue:[NSNumber numberWithInt:0] forKey:@"ps"];
|
id feedId = [self.activeFeed objectForKey:@"id"];
|
||||||
[self.activeFeed setValue:[NSNumber numberWithInt:0] forKey:@"nt"];
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId];
|
||||||
[self.activeFeed setValue:[NSNumber numberWithInt:0] forKey:@"ng"];
|
NSDictionary *feed = [self.dictFeeds objectForKey:feedIdStr];
|
||||||
|
|
||||||
|
[feed setValue:[NSNumber numberWithInt:0] forKey:@"ps"];
|
||||||
|
[feed setValue:[NSNumber numberWithInt:0] forKey:@"nt"];
|
||||||
|
[feed setValue:[NSNumber numberWithInt:0] forKey:@"ng"];
|
||||||
|
[self.dictFeeds setValue:feed forKey:feedIdStr];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)calculateStoryLocations {
|
- (void)calculateStoryLocations {
|
||||||
|
|
|
@ -72,12 +72,28 @@
|
||||||
- (void)viewWillAppear:(BOOL)animated {
|
- (void)viewWillAppear:(BOOL)animated {
|
||||||
[self.feedTitlesTable deselectRowAtIndexPath:[feedTitlesTable indexPathForSelectedRow]
|
[self.feedTitlesTable deselectRowAtIndexPath:[feedTitlesTable indexPathForSelectedRow]
|
||||||
animated:animated];
|
animated:animated];
|
||||||
if (appDelegate.activeFeedIndexPath && [appDelegate activeFeed]) {
|
// If there is an active feed, we need to update its table row to match
|
||||||
NSLog(@"Refreshing feed at %d / %d: %@", appDelegate.activeFeedIndexPath.section, appDelegate.activeFeedIndexPath.row, [appDelegate activeFeed]);
|
// the updated unread counts.
|
||||||
|
if ([appDelegate activeFeed]) {
|
||||||
|
NSMutableArray *indexPaths = [NSMutableArray array];
|
||||||
|
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 f=0; f < [activeFolderFeeds count]; f++) {
|
||||||
|
int location = [[activeFolderFeeds objectAtIndex:f] intValue];
|
||||||
|
id feedId = [originalFolder objectAtIndex:location];
|
||||||
|
if ([feedId compare:[appDelegate.activeFeed objectForKey:@"id"]] == NSOrderedSame) {
|
||||||
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:f inSection:s];
|
||||||
|
[indexPaths addObject:indexPath];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// NSLog(@"Refreshing feed at %@: %@", indexPaths, [appDelegate activeFeed]);
|
||||||
|
|
||||||
[self.feedTitlesTable beginUpdates];
|
[self.feedTitlesTable beginUpdates];
|
||||||
[self.feedTitlesTable
|
[self.feedTitlesTable
|
||||||
reloadRowsAtIndexPaths:[NSArray
|
reloadRowsAtIndexPaths:indexPaths
|
||||||
arrayWithObject:appDelegate.activeFeedIndexPath]
|
|
||||||
withRowAnimation:UITableViewRowAnimationNone];
|
withRowAnimation:UITableViewRowAnimationNone];
|
||||||
[self.feedTitlesTable endUpdates];
|
[self.feedTitlesTable endUpdates];
|
||||||
|
|
||||||
|
@ -106,7 +122,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated {
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
appDelegate.activeFeed = nil;
|
// appDelegate.activeFeed = nil;
|
||||||
[super viewDidAppear:animated];
|
[super viewDidAppear:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +176,7 @@
|
||||||
#pragma mark Initialization
|
#pragma mark Initialization
|
||||||
|
|
||||||
- (void)returnToApp {
|
- (void)returnToApp {
|
||||||
NSDate *decayDate = [[NSDate alloc] initWithTimeIntervalSinceNow:(-10*60)];
|
NSDate *decayDate = [[NSDate alloc] initWithTimeIntervalSinceNow:(BACKGROUND_REFRESH_SECONDS)];
|
||||||
NSLog(@"Last Update: %@ - %f", self.lastUpdate, [self.lastUpdate timeIntervalSinceDate:decayDate]);
|
NSLog(@"Last Update: %@ - %f", self.lastUpdate, [self.lastUpdate timeIntervalSinceDate:decayDate]);
|
||||||
if ([self.lastUpdate timeIntervalSinceDate:decayDate] < 0) {
|
if ([self.lastUpdate timeIntervalSinceDate:decayDate] < 0) {
|
||||||
[self fetchFeedList:YES];
|
[self fetchFeedList:YES];
|
||||||
|
@ -169,7 +185,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)fetchFeedList:(BOOL)showLoader {
|
- (void)fetchFeedList:(BOOL)showLoader {
|
||||||
// NSLog(@"fetchFeedList: %d %d", showLoader, appDelegate.navigationController.topViewController == appDelegate.feedsViewController);
|
// NSLog(@"fetchFeedList: %d %d %@", showLoader, appDelegate.navigationController.topViewController == appDelegate.feedsViewController, [appDelegate activeFeed]);
|
||||||
if (showLoader && appDelegate.navigationController.topViewController == appDelegate.feedsViewController) {
|
if (showLoader && appDelegate.navigationController.topViewController == appDelegate.feedsViewController) {
|
||||||
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
||||||
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||||
|
@ -192,7 +208,6 @@
|
||||||
[request startAsynchronous];
|
[request startAsynchronous];
|
||||||
|
|
||||||
self.lastUpdate = [NSDate date];
|
self.lastUpdate = [NSDate date];
|
||||||
[appDelegate setActiveFeedIndexPath:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)finishedWithError:(ASIHTTPRequest *)request {
|
- (void)finishedWithError:(ASIHTTPRequest *)request {
|
||||||
|
@ -415,7 +430,6 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
}
|
}
|
||||||
|
|
||||||
[appDelegate setActiveFeed:feed];
|
[appDelegate setActiveFeed:feed];
|
||||||
[appDelegate setActiveFeedIndexPath:indexPath];
|
|
||||||
appDelegate.readStories = [NSMutableArray array];
|
appDelegate.readStories = [NSMutableArray array];
|
||||||
|
|
||||||
[appDelegate loadFeedDetailView];
|
[appDelegate loadFeedDetailView];
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import "TestFlight.h"
|
// #import "TestFlight.h"
|
||||||
|
|
||||||
#define UIColorFromRGB(rgbValue) [UIColor \
|
#define UIColorFromRGB(rgbValue) [UIColor \
|
||||||
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
|
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
|
||||||
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
|
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
|
||||||
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
|
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
|
||||||
|
|
||||||
|
#define BACKGROUND_REFRESH_SECONDS -10*60
|
||||||
|
// #define BACKGROUND_REFRESH_SECONDS -5
|
||||||
|
|
||||||
// #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host:8000"]
|
// #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host:8000"]
|
||||||
#define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"]
|
#define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue