Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in getting feeds after a 'freeze' #84

Open
itemir opened this issue Aug 1, 2014 · 0 comments
Open

Problem in getting feeds after a 'freeze' #84

itemir opened this issue Aug 1, 2014 · 0 comments

Comments

@itemir
Copy link

itemir commented Aug 1, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant