mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: update ajaxifyTimer logic to only drop the request if the URL is the same as the one it's already processing
re: #12133
This commit is contained in:
@@ -17,6 +17,7 @@ ajaxify.widgets = { render: render };
|
|||||||
|
|
||||||
ajaxify.count = 0;
|
ajaxify.count = 0;
|
||||||
ajaxify.currentPage = null;
|
ajaxify.currentPage = null;
|
||||||
|
ajaxify.requestedPage = null;
|
||||||
// disables scroll to top when back button is clicked
|
// disables scroll to top when back button is clicked
|
||||||
// https://developer.chrome.com/blog/history-api-scroll-restoration/
|
// https://developer.chrome.com/blog/history-api-scroll-restoration/
|
||||||
if ('scrollRestoration' in history) {
|
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
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
ajaxifyTimer = Date.now();
|
ajaxifyTimer = Date.now();
|
||||||
|
ajaxify.requestedPage = url;
|
||||||
|
|
||||||
if (ajaxify.handleRedirects(url)) {
|
if (ajaxify.handleRedirects(url)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -134,6 +136,7 @@ ajaxify.widgets = { render: render };
|
|||||||
|
|
||||||
ajaxify.updateHistory = function (url, quiet) {
|
ajaxify.updateHistory = function (url, quiet) {
|
||||||
ajaxify.currentPage = url.split(/[?#]/)[0];
|
ajaxify.currentPage = url.split(/[?#]/)[0];
|
||||||
|
ajaxify.requestedPage = null;
|
||||||
if (window.history && window.history.pushState) {
|
if (window.history && window.history.pushState) {
|
||||||
window.history[!quiet ? 'pushState' : 'replaceState']({
|
window.history[!quiet ? 'pushState' : 'replaceState']({
|
||||||
url: url,
|
url: url,
|
||||||
|
|||||||
Reference in New Issue
Block a user