prevent freezing of inline search nav pager in some cases

This commit is contained in:
tophf 2017-12-13 07:46:28 +03:00
parent 6ee952f3d3
commit 0fe0423757

View File

@ -214,18 +214,21 @@ window.addEventListener('showStyles:done', function _() {
search({category}) search({category})
.then(function process(results) { .then(function process(results) {
const data = results.data.filter(sameCategory); const data = results.data.filter(sameCategory);
pass++; pass++;
if (pass === 1 && !data.length) { if (pass === 1 && !data.length) {
category = getCategory({keepTLD: true}); category = getCategory({keepTLD: true});
return search({category, restart: true}).then(process); return search({category, restart: true}).then(process);
} }
const numIrrelevant = results.data.length - data.length; const numIrrelevant = results.data.length - data.length;
totalResults = results.current_page === 1 ? results.total_entries : totalResults; totalResults = results.current_page === 1 ? results.total_entries : totalResults;
totalResults = Math.max(0, totalResults - numIrrelevant); totalResults = Math.max(0, totalResults - numIrrelevant);
totalPages = Math.ceil(totalResults / DISPLAY_PER_PAGE); totalPages = Math.ceil(totalResults / DISPLAY_PER_PAGE);
setLoading(false);
if (data.length) { if (data.length) {
setLoading(false);
unprocessedResults.push(...data); unprocessedResults.push(...data);
processNextResult(); processNextResult();
} else if (numIrrelevant) { } else if (numIrrelevant) {