Search optimizations and fixes. Prevent re-renders on hash change (redux). Clear previous search results at the start of a new search.

This commit is contained in:
2026-01-31 22:37:47 +00:00
parent f94ccc01c6
commit d15bfc86c4
4 changed files with 148 additions and 93 deletions
+5 -9
View File
@@ -33,17 +33,14 @@ const props = defineProps<{
// Folder path for component keys - only recreate component when folder changes, not search
const folderPath = computed(() => props.path.join('/'))
// Trigger search when query changes (from route, e.g., page load or back button)
// Note: Direct typing triggers search immediately via HeaderMain, this is for route-based changes
// Handle route-based search changes (back/forward navigation, direct URL)
// Skip if store.query already matches (means we triggered this via typing)
watch(
() => [props.query, props.path.join('/')] as const,
([query, loc]) => {
// Only trigger if results don't match current query (avoid duplicate searches)
if (query && store.searchResults.length === 0) {
store.search(query, loc)
} else if (!query) {
store.search('', loc) // Clear search results
}
if (store.query === query) return // Already searching this query
store.search(query, loc)
},
{ immediate: true }
)
@@ -71,7 +68,6 @@ const documents = computed(() => {
watchEffect(() => {
store.fileExplorer = fileExplorer.value
store.query = props.query
})
// Only auto-switch gallery mode when entering a new folder or on initial file list load