From 5463a7c72303d72554e02eacbef903e6e576d8c0 Mon Sep 17 00:00:00 2001 From: Adeel Date: Mon, 3 Apr 2017 16:50:47 +0500 Subject: [PATCH] retry on error for both kinds of searches --- background.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index 0fa3a72..fbdc5bb 100644 --- a/background.js +++ b/background.js @@ -44,6 +44,8 @@ function autoFind(tabId, url) { } } +const BG_RETRY_INTERVAL = 5e3; + function searchExact(tabId, url) { findOnReddit(url, true, true) .then(posts => { @@ -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}`))