From b4297cd8f065a94e7de5a3ad4b992e61c9234ca0 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 1 Nov 2023 10:54:41 -0400 Subject: [PATCH] fix: update ajaxifyTimer logic to only drop the request if the URL is the same as the one it's already processing re: #12133 --- public/src/ajaxify.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index bff7a330f2..8423f27fd8 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -17,6 +17,7 @@ ajaxify.widgets = { render: render }; ajaxify.count = 0; ajaxify.currentPage = null; + ajaxify.requestedPage = null; // disables scroll to top when back button is clicked // https://developer.chrome.com/blog/history-api-scroll-restoration/ if ('scrollRestoration' in history) { @@ -38,10 +39,11 @@ ajaxify.widgets = { render: render }; } // Abort subsequent requests if clicked multiple times within a short window of time - if (ajaxifyTimer && (Date.now() - ajaxifyTimer) < 500) { + if (ajaxify.requestedPage === url && ajaxifyTimer && (Date.now() - ajaxifyTimer) < 500) { return true; } ajaxifyTimer = Date.now(); + ajaxify.requestedPage = url; if (ajaxify.handleRedirects(url)) { return true; @@ -134,6 +136,7 @@ ajaxify.widgets = { render: render }; ajaxify.updateHistory = function (url, quiet) { ajaxify.currentPage = url.split(/[?#]/)[0]; + ajaxify.requestedPage = null; if (window.history && window.history.pushState) { window.history[!quiet ? 'pushState' : 'replaceState']({ url: url,