Fixed bug where "Searching..." label wouldn't disappear
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
import { cacheManager } from '../cache-manager'
|
import { cacheManager } from '../cache-manager'
|
||||||
import { searchEngine } from 'src/search/omnisearch'
|
import { searchEngine } from 'src/search/omnisearch'
|
||||||
import { cancelable, CancelablePromise } from 'cancelable-promise'
|
import { cancelable, CancelablePromise } from 'cancelable-promise'
|
||||||
|
import { debounce } from 'lodash-es'
|
||||||
|
|
||||||
export let modal: OmnisearchVaultModal
|
export let modal: OmnisearchVaultModal
|
||||||
export let previousQuery: string | undefined
|
export let previousQuery: string | undefined
|
||||||
@@ -59,10 +60,7 @@
|
|||||||
createInCurrentPaneKey = 'shift ↵'
|
createInCurrentPaneKey = 'shift ↵'
|
||||||
}
|
}
|
||||||
$: if (searchQuery) {
|
$: if (searchQuery) {
|
||||||
searching = true
|
updateResultsDebounced()
|
||||||
updateResults().then(() => {
|
|
||||||
searching = false
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
searching = false
|
searching = false
|
||||||
resultNotes = []
|
resultNotes = []
|
||||||
@@ -79,11 +77,11 @@
|
|||||||
indexingStepDesc = 'Indexing files...'
|
indexingStepDesc = 'Indexing files...'
|
||||||
break
|
break
|
||||||
case IndexingStepType.WritingCache:
|
case IndexingStepType.WritingCache:
|
||||||
updateResults()
|
updateResultsDebounced()
|
||||||
indexingStepDesc = 'Updating cache...'
|
indexingStepDesc = 'Updating cache...'
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
updateResults()
|
updateResultsDebounced()
|
||||||
indexingStepDesc = ''
|
indexingStepDesc = ''
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -102,6 +100,7 @@
|
|||||||
eventBus.on('vault', Action.PrevSearchHistory, prevSearchHistory)
|
eventBus.on('vault', Action.PrevSearchHistory, prevSearchHistory)
|
||||||
eventBus.on('vault', Action.NextSearchHistory, nextSearchHistory)
|
eventBus.on('vault', Action.NextSearchHistory, nextSearchHistory)
|
||||||
await NotesIndex.refreshIndex()
|
await NotesIndex.refreshIndex()
|
||||||
|
await updateResultsDebounced()
|
||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
@@ -129,6 +128,7 @@
|
|||||||
|
|
||||||
let cancelableQuery: CancelablePromise<ResultNote[]> | null = null
|
let cancelableQuery: CancelablePromise<ResultNote[]> | null = null
|
||||||
async function updateResults() {
|
async function updateResults() {
|
||||||
|
searching = true
|
||||||
// If search is already in progress, cancel it and start a new one
|
// If search is already in progress, cancel it and start a new one
|
||||||
if (cancelableQuery) {
|
if (cancelableQuery) {
|
||||||
cancelableQuery.cancel()
|
cancelableQuery.cancel()
|
||||||
@@ -143,8 +143,11 @@
|
|||||||
resultNotes = await cancelableQuery
|
resultNotes = await cancelableQuery
|
||||||
selectedIndex = 0
|
selectedIndex = 0
|
||||||
await scrollIntoView()
|
await scrollIntoView()
|
||||||
|
searching = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateResultsDebounced = debounce(updateResults, 100)
|
||||||
|
|
||||||
function onClick(evt?: MouseEvent | KeyboardEvent) {
|
function onClick(evt?: MouseEvent | KeyboardEvent) {
|
||||||
if (!selectedNote) return
|
if (!selectedNote) return
|
||||||
if (evt?.ctrlKey) {
|
if (evt?.ctrlKey) {
|
||||||
|
|||||||
Reference in New Issue
Block a user