Skip to content

Commit

Permalink
avoid API Limit Exceeded with delayed fetch bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dataich committed Mar 23, 2011
1 parent 8fba701 commit f17c806
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Diibar/DiibarAppDelegate.h
Expand Up @@ -32,6 +32,7 @@
@property (assign) IBOutlet NSPanel *_preferencesPanel;

- (void)getBookmarks;
- (void)fetchBookmarksWithDelay;
- (void)fetchBookmarks;
- (void)getBrowsers;
- (NSMenuItem*)createBookmarkItem:(NSString*)title url:(NSString*)url;
Expand Down
15 changes: 12 additions & 3 deletions Diibar/DiibarAppDelegate.m
Expand Up @@ -20,6 +20,7 @@ @implementation DiibarAppDelegate
static const NSInteger maxRecent = 100;
static const NSInteger defaultBrowser = 999;
static const NSInteger retryCount = 10;
static const NSInteger duration = 3;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
Expand Down Expand Up @@ -89,7 +90,15 @@ - (void)getBookmarks {

_jsonArray = [[NSMutableArray alloc] init];
_start = 0;
[self fetchBookmarks];
[self fetchBookmarksWithDelay];
}

- (void)fetchBookmarksWithDelay {
[NSTimer scheduledTimerWithTimeInterval:duration
target:self
selector:@selector(fetchBookmarks)
userInfo:nil
repeats:NO];
}

- (void)fetchBookmarks {
Expand Down Expand Up @@ -306,7 +315,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
if(0 < [json count]) {
[_jsonArray addObjectsFromArray:json];
_start = _start + count;
[self fetchBookmarks];
[self fetchBookmarksWithDelay];
} else {
[self savePlist];
[self createBookmarkItems];
Expand All @@ -321,7 +330,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self createBookmarkItems];

} else {
[self fetchBookmarks];
[self fetchBookmarksWithDelay];
}


Expand Down

0 comments on commit f17c806

Please sign in to comment.