Skip to content

Commit

Permalink
Mark articles opened in the browser as read.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewpalmer authored and stevewpalmer committed Jun 16, 2011
1 parent c5d0dd4 commit ddbd1f4
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions 2.6.0/AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2406,17 +2406,21 @@ -(void)viewArticlePages:(id)sender inPreferredBrowser:(BOOL)usePreferredBrowser
// Launch in the foreground or background as needed
BOOL openLinksInBackground = [prefs openLinksInBackground];

NSMutableArray *urls = [NSMutableArray arrayWithCapacity:[articleArray count]];
NSMutableArray * articlesWithLinks = [NSMutableArray arrayWithCapacity:[articleArray count]];
NSMutableArray * urls = [NSMutableArray arrayWithCapacity:[articleArray count]];

for (currentArticle in articleArray)
{
if (currentArticle && ![[currentArticle link] isBlank])
{
[articlesWithLinks addObject:currentArticle];
[urls addObject:[NSURL URLWithString:[currentArticle link]]];
}
}

// CHANGEME: mark articles that were successfully opened as read
#define URL_COUNT_TO_OPEN_IN_ONE_GO 4
#define URL_COUNT_TO_OPEN_IN_ONE_GO 4
#define DEBUG_LOG_OPEN_MULTIPLE_PAGES 0

double delayTime = 1.0;
BOOL initialDelay = NO;

Expand Down Expand Up @@ -2452,13 +2456,17 @@ -(void)viewArticlePages:(id)sender inPreferredBrowser:(BOOL)usePreferredBrowser

if (err == noErr)
{
#if DEBUG_LOG_OPEN_MULTIPLE_PAGES
NSLog(@"Successfully opened %lu URL(s).", (unsigned long)theRange.length);
#endif
openedSuccessfully = YES;
break;
}
else if (err == errAETimeout)
{
#if DEBUG_LOG_OPEN_MULTIPLE_PAGES
NSLog(@"Failed to opened %lu URL(s): timeout. Trying again.", (unsigned long)theRange.length);
#endif
initialDelay = YES;
}
else
Expand All @@ -2468,9 +2476,16 @@ -(void)viewArticlePages:(id)sender inPreferredBrowser:(BOOL)usePreferredBrowser

}

if (!openedSuccessfully)
if (openedSuccessfully)
{
if (![db readOnly])
[articleController markReadByArray:articlesWithLinks readFlag:YES];
}
else
{
#if DEBUG_LOG_OPEN_MULTIPLE_PAGES
NSLog(@"Failed to opened %lu URL(s). Giving up.", (unsigned long)theRange.length);
#endif
}

}
Expand Down

0 comments on commit ddbd1f4

Please sign in to comment.