-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I noticed an issue which I suspected to be a bug. If you use the application for a while and then close it by pressing the home button, when you come back to the application after several hours it seems to be missing updates that has taken place in between.
The query to the server seems to be made every 10 seconds with a time span of 5 minutes (if the app is running) or with a span of 1 week (if the app has just been started). By debugging, I figured after a several hour 'freeze' period, the app continues to use 5 minute spans for queries which can cause it to miss updates that happened beyond those 5 minute spans.
I think there is a better way to do this by storing the timestamp when a feed update is made and using it as the starting point in the next query.
Making a long story short, here is how I fixed this for myself:
in EZRFeedItemUpdateService.m:
Added the following
-
(void)requestFeedItemsSinceLastFeedUpdate:(id)sender
{
NSDate *now = [NSDate date];NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDate *lastFeedUpdate = [defaults objectForKey:@"lastFeedUpdate"];[self requestFeedItemsSince:lastFeedUpdate];
[defaults setValue:now forKey:@"lastFeedUpdate"];
[defaults synchronize];NSLog(@"lastFeedUpdate in standardUserDefaults updated!");
NSLog(@"Invocation ran!");
}
Modified the startup code section to:
-
(void) start
{
if (![self hasSetDefaultFeeds])
{
NSDate *now = [NSDate date];[self loadDefaultFeeds]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setValue:now forKey:@"lastFeedUpdate"]; [defaults synchronize]; }else {
NSDate *now = [NSDate date];// 7 day pull is probably an overkill and will not be needed with // the implementation of lastFeedUpdate but leaving as a 'safety' mechanism [self requestOneWeekOfFeedItems]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setValue:now forKey:@"lastFeedUpdate"]; [defaults synchronize];}
......
[myInvocation setSelector:@selector(requestFeedItemsSinceLastFeedUpdate:)];
Sharing in case someone hits into a similar problem or wants to build more into it.