Search fix.

This commit is contained in:
retoor 2025-11-12 05:05:48 +01:00
parent f82079ff27
commit b8d30af69e
2 changed files with 9 additions and 2 deletions

View File

@ -18,8 +18,10 @@ export class FileList extends HTMLElement {
this.addEventListener('click', this.boundHandleClick);
this.addEventListener('dblclick', this.boundHandleDblClick);
this.addEventListener('change', this.boundHandleChange);
if (!this.hasAttribute('data-search-mode')) {
await this.loadContents(null);
}
}
disconnectedCallback() {
this.removeEventListener('click', this.boundHandleClick);

View File

@ -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 = `
<div class="search-results">
@ -580,9 +583,11 @@ export class RBoxApp extends HTMLElement {
fileList.setFiles(files);
this.attachListeners();
} catch (error) {
if (searchId === this.currentSearchId) {
console.error('Search failed:', error);
}
}
}
switchView(view, pushState = true) {
this.closeAllOverlays();