Search fix.
This commit is contained in:
parent
f82079ff27
commit
b8d30af69e
@ -18,8 +18,10 @@ export class FileList extends HTMLElement {
|
|||||||
this.addEventListener('click', this.boundHandleClick);
|
this.addEventListener('click', this.boundHandleClick);
|
||||||
this.addEventListener('dblclick', this.boundHandleDblClick);
|
this.addEventListener('dblclick', this.boundHandleDblClick);
|
||||||
this.addEventListener('change', this.boundHandleChange);
|
this.addEventListener('change', this.boundHandleChange);
|
||||||
|
if (!this.hasAttribute('data-search-mode')) {
|
||||||
await this.loadContents(null);
|
await this.loadContents(null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
this.removeEventListener('click', this.boundHandleClick);
|
this.removeEventListener('click', this.boundHandleClick);
|
||||||
|
|||||||
@ -28,6 +28,7 @@ export class RBoxApp extends HTMLElement {
|
|||||||
this.navigationStack = [];
|
this.navigationStack = [];
|
||||||
this.boundHandlePopState = this.handlePopState.bind(this);
|
this.boundHandlePopState = this.handlePopState.bind(this);
|
||||||
this.popstateAttached = false;
|
this.popstateAttached = false;
|
||||||
|
this.currentSearchId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async connectedCallback() {
|
async connectedCallback() {
|
||||||
@ -567,8 +568,10 @@ export class RBoxApp extends HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async performSearch(query) {
|
async performSearch(query) {
|
||||||
|
const searchId = ++this.currentSearchId;
|
||||||
try {
|
try {
|
||||||
const files = await api.searchFiles(query);
|
const files = await api.searchFiles(query);
|
||||||
|
if (searchId !== this.currentSearchId) return;
|
||||||
const mainContent = this.querySelector('#main-content');
|
const mainContent = this.querySelector('#main-content');
|
||||||
mainContent.innerHTML = `
|
mainContent.innerHTML = `
|
||||||
<div class="search-results">
|
<div class="search-results">
|
||||||
@ -580,9 +583,11 @@ export class RBoxApp extends HTMLElement {
|
|||||||
fileList.setFiles(files);
|
fileList.setFiles(files);
|
||||||
this.attachListeners();
|
this.attachListeners();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (searchId === this.currentSearchId) {
|
||||||
console.error('Search failed:', error);
|
console.error('Search failed:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switchView(view, pushState = true) {
|
switchView(view, pushState = true) {
|
||||||
this.closeAllOverlays();
|
this.closeAllOverlays();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user