Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

fix: keep the page loader hidden once the page has shown itself, a late overlay timer could re-add it after /account finished loading and leave the page covered

Murtaza Nasir59097f04bf2b
diff --git a/static/js/loading.js b/static/js/loading.js
index 630a59ad..7aa21d4f 100644
--- a/static/js/loading.js
+++ b/static/js/loading.js
@@ -12,7 +12,7 @@ window.AppLoader = {
* Initialize the loading system
*/
init() {
- if (this.initialized) return;
+ if (this.initialized || window.__appLoaderHidden) return;
this.initialized = true;
this.initTime = Date.now();
@@ -103,6 +103,9 @@ window.AppLoader = {
* Hide the loading overlay
*/
hide() {
+ // Remembered so a late init (either overlay script) cannot bring the
+ // overlay back after the page has shown itself.
+ window.__appLoaderHidden = true;
try {
// Remove app-loading class immediately to show content
document.body.classList.remove('app-loading');
diff --git a/templates/includes/loading_overlay.html b/templates/includes/loading_overlay.html
index 178cb62d..817a5f0c 100644
--- a/templates/includes/loading_overlay.html
+++ b/templates/includes/loading_overlay.html
@@ -52,6 +52,11 @@
// Immediate loading overlay initialization
(function() {
function initLoadingOverlay() {
+ // If the page already finished initialising and hid the loader,
+ // adding the overlay now would cover the page for good. This
+ // happens when the timer below fires after a fast page init
+ // (seen on /account), since that page has no timeout fallback.
+ if (window.__appLoaderHidden) return;
if (!document.body) {
// Body not ready yet, wait a bit
setTimeout(initLoadingOverlay, 10);