From 266fc26e16ed76dc6218abfd244f36cfc71b5193 Mon Sep 17 00:00:00 2001 From: Edouard Vanbelle Date: Mon, 23 Mar 2026 13:16:31 +0100 Subject: [PATCH] feat(fileview) show loader only if requests take more than 100ms --- static/js/app/filesView.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/static/js/app/filesView.js b/static/js/app/filesView.js index c2c1ba9f..882cdd47 100644 --- a/static/js/app/filesView.js +++ b/static/js/app/filesView.js @@ -125,12 +125,16 @@ async function loadFiles(options = { insertHistory: true}) { window.isLoadingFiles = true; - elements.filesGrid.innerHTML = ` -
-
- ${window.i18n ? window.i18n.t('files.loading') : 'Loading files…'} -
- `; + // This to avoid blinking page, a better solution would be to put loading on an overlay and remove timeout + let loadingFiles = setTimeout( () => { + // display loader after few delay (will be canceled if result take less time) + elements.filesGrid.innerHTML = ` +
+
+ ${window.i18n ? window.i18n.t('files.loading') : 'Loading files…'} +
+ `; + }, 100); if (!app.userHomeFolderId) { await window.resolveHomeFolder(); @@ -186,6 +190,9 @@ async function loadFiles(options = { insertHistory: true}) { console.log(`Loading listing from ${url}`); const response = await fetch(url, requestOptions); + // not required anymore + clearTimeout( loadingFiles); + if (response.status === 401 || response.status === 403) { console.warn("Auth error when loading files, showing empty list"); elements.filesGrid.innerHTML = '

Could not load files

';