aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.rs
diff options
context:
space:
mode:
authorLukas Stabe <lukas@stabe.de>2025-03-09 09:17:40 +0000
committerLukas Stabe <lukas@stabe.de>2025-03-09 09:18:14 +0000
commit8507fdec3e186cca207c526b1f31bb8148a97e60 (patch)
tree5124386ec403cc0f26992f46038e4e382f7266fd /src/renderer.rs
parentRewrite file traversal logic to not suffer from stack overflow problem (diff)
downloadminiserve-8507fdec3e186cca207c526b1f31bb8148a97e60.tar.gz
miniserve-8507fdec3e186cca207c526b1f31bb8148a97e60.zip
fix loading animation and row height jumping while loading dir sizes
Diffstat (limited to 'src/renderer.rs')
-rw-r--r--src/renderer.rs22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/renderer.rs b/src/renderer.rs
index 6a8b808..3f67695 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -687,21 +687,6 @@ fn page_header(
}).then(resp => resp.ok ? resp.text() : "~")
}
- // Initialize shimmer effects for .size-cell elements in .entry-type-directory rows
- //
- // TODO: Perhaps it'd be better to statically do this during html generation in
- // entry_row()?
- function initializeLoadingIndicators() {
- const directoryCells = document.querySelectorAll('tr.entry-type-directory .size-cell');
-
- directoryCells.forEach(cell => {
- // Add a loading indicator to each cell
- const loadingIndicator = document.createElement('div');
- loadingIndicator.className = 'loading-indicator';
- cell.appendChild(loadingIndicator);
- });
- }
-
function updateSizeCells() {
const directoryCells = document.querySelectorAll('tr.entry-type-directory .size-cell');
@@ -712,12 +697,10 @@ fn page_header(
// First check our local cache
if (target in dirSizeCache) {
- cell.innerHTML = '';
- cell.textContent = dirSizeCache[target];
+ cell.dataset.size = dirSizeCache[target];
} else {
fetchDirSize(target).then(dir_size => {
- cell.innerHTML = '';
- cell.textContent = dir_size;
+ cell.dataset.size = dir_size;
dirSizeCache[target] = dir_size;
})
.catch(error => console.error("Error fetching dir size:", error));
@@ -725,7 +708,6 @@ fn page_header(
})
}
setInterval(updateSizeCells, 1000);
- window.addEventListener('load', initializeLoadingIndicators);
"#))
}