BlueGit

timfa filemanager

fix: load folder icons in folder-only views and roots view

timfa Tim Falken · pushed by timfa

Authored 2026-05-04 · 6 months ago

Hash
9c9eda8528e8fbd139f6a229f001e7c5be9ab166
Parent
9b75b60c
2 files changed +20 −2
public/app.js +6 −2
@@ -696,6 +696,10 @@ async function loadRoots (opts = {})
696 696
697 697 function renderRootsView ()
698 698 {
699 disconnectThumbnailObserver();
700 disconnectFolderIconObserver();
701 revokeThumbnails();
702
699 703 STATE.currentDir = null;
700 704 STATE.currentRoot = null;
701 705 saveSessionState();
@@ -711,6 +715,8 @@ function renderRootsView ()
711 715 const el = makeFileItem({ name: root.label, isDir: true, path: root.path, _root: root });
712 716 grid.appendChild(el);
713 717 }
718
719 loadThumbnails();
714 720 }
715 721
716 722 async function navigateTo (absPath, root, opts = {})
@@ -3048,8 +3054,6 @@ function observeThumbnailIcon (iconEl)
3048 3054 async function loadThumbnails ()
3049 3055 {
3050 3056 const icons = Array.from(document.querySelectorAll('.icon[data-preview-path]'));
3051 if (!icons.length) return;
3052
3053 3057 for (const icon of icons)
3054 3058 {
3055 3059 observeThumbnailIcon(icon);
@@ -696,6 +696,10 @@ async function loadRoots (opts = {})
696
696
697function renderRootsView ()
697function renderRootsView ()
698{
698{
699 disconnectThumbnailObserver();
700 disconnectFolderIconObserver();
701 revokeThumbnails();
702
699 STATE.currentDir = null;
703 STATE.currentDir = null;
700 STATE.currentRoot = null;
704 STATE.currentRoot = null;
701 saveSessionState();
705 saveSessionState();
@@ -711,6 +715,8 @@ function renderRootsView ()
711 const el = makeFileItem({ name: root.label, isDir: true, path: root.path, _root: root });
715 const el = makeFileItem({ name: root.label, isDir: true, path: root.path, _root: root });
712 grid.appendChild(el);
716 grid.appendChild(el);
713 }
717 }
718
719 loadThumbnails();
714}
720}
715
721
716async function navigateTo (absPath, root, opts = {})
722async function navigateTo (absPath, root, opts = {})
@@ -3048,8 +3054,6 @@ function observeThumbnailIcon (iconEl)
3048async function loadThumbnails ()
3054async function loadThumbnails ()
3049{
3055{
3050 const icons = Array.from(document.querySelectorAll('.icon[data-preview-path]'));
3056 const icons = Array.from(document.querySelectorAll('.icon[data-preview-path]'));
3051 if (!icons.length) return;
3052
3053 for (const icon of icons)
3057 for (const icon of icons)
3054 {
3058 {
3055 observeThumbnailIcon(icon);
3059 observeThumbnailIcon(icon);
tests/page.load.test.js +14 −0
@@ -252,6 +252,9 @@ describe('page load smoke test', () =>
252 252 '/data-a': { usedBytes: 2048, freeBytes: 4096 },
253 253 '/data-b': { usedBytes: 1024, freeBytes: 8192 },
254 254 };
255 folderIconFixture = {
256 '/data-a': { filePath: '/data-a/docs/cover.jpg' },
257 };
255 258
256 259 const { dom, runtimeErrors } = await bootClient({
257 260 savedSession: {
@@ -274,6 +277,17 @@ describe('page load smoke test', () =>
274 277 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Used');
275 278 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Remaining');
276 279
280 let rootIconImage = null;
281 for (let i = 0; i < 10; i++)
282 {
283 const rootIconSvg = rootTile.querySelector('.icon svg');
284 rootIconImage = rootIconSvg ? rootIconSvg.querySelector('image') : null;
285 if (rootIconImage) break;
286 await new Promise(resolve => dom.window.setTimeout(resolve, 25));
287 }
288 // Root tiles should load folder icon thumbnails in Home view.
289 expect(rootIconImage).toBeTruthy();
290
277 291 rootTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
278 292 await new Promise(resolve => dom.window.setTimeout(resolve, 80));
279 293
@@ -252,6 +252,9 @@ describe('page load smoke test', () =>
252 '/data-a': { usedBytes: 2048, freeBytes: 4096 },
252 '/data-a': { usedBytes: 2048, freeBytes: 4096 },
253 '/data-b': { usedBytes: 1024, freeBytes: 8192 },
253 '/data-b': { usedBytes: 1024, freeBytes: 8192 },
254 };
254 };
255 folderIconFixture = {
256 '/data-a': { filePath: '/data-a/docs/cover.jpg' },
257 };
255
258
256 const { dom, runtimeErrors } = await bootClient({
259 const { dom, runtimeErrors } = await bootClient({
257 savedSession: {
260 savedSession: {
@@ -274,6 +277,17 @@ describe('page load smoke test', () =>
274 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Used');
277 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Used');
275 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Remaining');
278 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Remaining');
276
279
280 let rootIconImage = null;
281 for (let i = 0; i < 10; i++)
282 {
283 const rootIconSvg = rootTile.querySelector('.icon svg');
284 rootIconImage = rootIconSvg ? rootIconSvg.querySelector('image') : null;
285 if (rootIconImage) break;
286 await new Promise(resolve => dom.window.setTimeout(resolve, 25));
287 }
288 // Root tiles should load folder icon thumbnails in Home view.
289 expect(rootIconImage).toBeTruthy();
290
277 rootTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
291 rootTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
278 await new Promise(resolve => dom.window.setTimeout(resolve, 80));
292 await new Promise(resolve => dom.window.setTimeout(resolve, 80));
279
293