From 0fe04237579a6b739fb0342bce47bfccd0b623ee Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 13 Dec 2017 07:46:28 +0300 Subject: [PATCH] prevent freezing of inline search nav pager in some cases --- popup/search-results.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/popup/search-results.js b/popup/search-results.js index b174365e..2c359214 100755 --- a/popup/search-results.js +++ b/popup/search-results.js @@ -214,18 +214,21 @@ window.addEventListener('showStyles:done', function _() { search({category}) .then(function process(results) { const data = results.data.filter(sameCategory); + pass++; if (pass === 1 && !data.length) { category = getCategory({keepTLD: true}); return search({category, restart: true}).then(process); } + const numIrrelevant = results.data.length - data.length; totalResults = results.current_page === 1 ? results.total_entries : totalResults; totalResults = Math.max(0, totalResults - numIrrelevant); totalPages = Math.ceil(totalResults / DISPLAY_PER_PAGE); + setLoading(false); + if (data.length) { - setLoading(false); unprocessedResults.push(...data); processNextResult(); } else if (numIrrelevant) {