From b8d30af69ee77a8f864904956566e6df0c719c44 Mon Sep 17 00:00:00 2001 From: retoor Date: Wed, 12 Nov 2025 05:05:48 +0100 Subject: [PATCH] Search fix. --- static/js/components/file-list.js | 4 +++- static/js/components/rbox-app.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/static/js/components/file-list.js b/static/js/components/file-list.js index b8c29cc..f731758 100644 --- a/static/js/components/file-list.js +++ b/static/js/components/file-list.js @@ -18,7 +18,9 @@ export class FileList extends HTMLElement { this.addEventListener('click', this.boundHandleClick); this.addEventListener('dblclick', this.boundHandleDblClick); this.addEventListener('change', this.boundHandleChange); - await this.loadContents(null); + if (!this.hasAttribute('data-search-mode')) { + await this.loadContents(null); + } } disconnectedCallback() { diff --git a/static/js/components/rbox-app.js b/static/js/components/rbox-app.js index ff1cf08..86805e6 100644 --- a/static/js/components/rbox-app.js +++ b/static/js/components/rbox-app.js @@ -28,6 +28,7 @@ export class RBoxApp extends HTMLElement { this.navigationStack = []; this.boundHandlePopState = this.handlePopState.bind(this); this.popstateAttached = false; + this.currentSearchId = 0; } async connectedCallback() { @@ -567,8 +568,10 @@ export class RBoxApp extends HTMLElement { } async performSearch(query) { + const searchId = ++this.currentSearchId; try { const files = await api.searchFiles(query); + if (searchId !== this.currentSearchId) return; const mainContent = this.querySelector('#main-content'); mainContent.innerHTML = `
@@ -580,7 +583,9 @@ export class RBoxApp extends HTMLElement { fileList.setFiles(files); this.attachListeners(); } catch (error) { - console.error('Search failed:', error); + if (searchId === this.currentSearchId) { + console.error('Search failed:', error); + } } }