Skip to content

Commit

Permalink
retry on error for both kinds of searches
Browse files Browse the repository at this point in the history
  • Loading branch information
AdeelH committed Apr 3, 2017
1 parent 03c3fca commit 5463a7c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function autoFind(tabId, url) {
}
}

const BG_RETRY_INTERVAL = 5e3;

function searchExact(tabId, url) {
findOnReddit(url, true, true)
.then(posts => {
Expand All @@ -53,10 +55,14 @@ function searchExact(tabId, url) {
setResultsBadge(tabId, `${posts.length}`);
}
})
.catch(e => handleError(e, tabId));
.catch(e => {
if (bgOpts.autorun.retryError) {
setTimeout(() => searchExact(tabId, url), BG_RETRY_INTERVAL);
}
handleError(e, tabId);
});
}

const BG_RETRY_INTERVAL = 5e3;
function searchNonExact(tabId, url) {
findOnReddit(url, true, false)
.then(posts => setResultsBadge(tabId, `${posts.length}`))
Expand Down

0 comments on commit 5463a7c

Please sign in to comment.