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})
.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);
if (data.length) {
setLoading(false);
if (data.length) {
unprocessedResults.push(...data);
processNextResult();
} else if (numIrrelevant) {