From: Radek Czajka Date: Fri, 9 Jun 2023 15:49:36 +0000 (+0200) Subject: fix race in filters X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/2aff714cb52d85d39824728d70b3272bb4fd5064?ds=sidebyside fix race in filters --- diff --git a/src/catalogue/static/2022/book/filter.js b/src/catalogue/static/2022/book/filter.js index 59e810a48..43b6c4e40 100644 --- a/src/catalogue/static/2022/book/filter.js +++ b/src/catalogue/static/2022/book/filter.js @@ -8,10 +8,17 @@ function get_page(page, search, ordering, callback) { get_page_by_url('.?page=' + page + '&order=' + ordering + '&search=' + search, callback); } + + let lastFulfilledPage = 0; + function get_page_by_url(url, callback) { + let requestTime = + new Date(); $.get( url, function(data) { + if (lastFulfilledPage > requestTime) return; + lastFulfilledPage = requestTime; + html = $(data); objectList = $('#object-list', html); paginate = $('#paginate', html);