From dcf29ec63e419614ef25458bc1536405b6179fe7 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 15 Jul 2021 18:38:16 +0200 Subject: [PATCH] Add workaround for issue with "back" button in Safari --- src/pretix/static/pretixbase/js/asynctask.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pretix/static/pretixbase/js/asynctask.js b/src/pretix/static/pretixbase/js/asynctask.js index a162de69e..e4c9ec46a 100644 --- a/src/pretix/static/pretixbase/js/asynctask.js +++ b/src/pretix/static/pretixbase/js/asynctask.js @@ -228,6 +228,17 @@ $(function () { } ); }); + + window.addEventListener("pageshow", function (evt) { + // In Safari, if you submit an async task, then get redirected, then go back, + // Safari won't reload the HTML from disk cache but instead reuse the DOM of the + // previous request, thus not clearing the "loading" state. + if (evt.persisted && $("body").hasClass("loading")) { + setTimeout(function () { + window.location.reload(); + }, 10); + } + }, false); }); var waitingDialog = {