From c21d44a16991c0a4632c91299e6bfd93e3de7506 Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Tue, 30 Jun 2026 12:26:32 +0200 Subject: [PATCH] added loading indicator for large vaults --- frontend/app.js | 21 +++++++++++++++++++++ frontend/index.html | 44 +++++++++++++++++++++++++++++++++++++++----- locales/de-DE.json | 1 + locales/en-GB.json | 1 + locales/en-US.json | 1 + locales/es-ES.json | 1 + locales/fr-FR.json | 1 + locales/hu-HU.json | 1 + locales/it-IT.json | 1 + locales/ja-JP.json | 1 + locales/ru-RU.json | 1 + locales/sl-SI.json | 1 + locales/zh-CN.json | 1 + 13 files changed, 71 insertions(+), 5 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index 5ff7d7d..fcab43f 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -262,6 +262,13 @@ function noteApp() { alreadyDonated: false, autosaveDelayMs: CONFIG.AUTOSAVE_DELAY, // hydrated from /api/config in loadConfig() notes: [], + + // True while /api/notes is in flight. Drives the "Loading your vault…" + // placeholder + the delayed overlay (notesLoadingShowOverlay). + notesLoading: true, + notesLoadingShowOverlay: false, + _notesLoadingOverlayTimer: null, + currentNote: '', currentNoteName: '', noteContent: '', @@ -1524,6 +1531,16 @@ function noteApp() { // Load all notes async loadNotes() { + this.notesLoading = true; + // Show the overlay only if we're still loading after 800ms AND + // the tree is currently empty (first load). Refreshes after a + // save typically resolve in <100ms and never trip this. + clearTimeout(this._notesLoadingOverlayTimer); + this._notesLoadingOverlayTimer = setTimeout(() => { + if (this.notesLoading && this.notes.length === 0 && this.allFolders.length === 0) { + this.notesLoadingShowOverlay = true; + } + }, 800); try { const response = await fetch('/api/notes'); const data = await response.json(); @@ -1534,6 +1551,10 @@ function noteApp() { await this.loadTags(); // Load tags after notes are loaded } catch (error) { ErrorHandler.handle('load notes', error); + } finally { + clearTimeout(this._notesLoadingOverlayTimer); + this.notesLoading = false; + this.notesLoadingShowOverlay = false; } }, diff --git a/frontend/index.html b/frontend/index.html index a167237..228be3a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1397,7 +1397,30 @@ - + + +
+
+ + + + + +
+
+