throttle search progress again
This commit is contained in:
parent
a20359c6a8
commit
3f9a7def75
|
@ -12,7 +12,8 @@
|
||||||
STATE_EXPANDED,
|
STATE_EXPANDED,
|
||||||
STATE_LIMIT,
|
STATE_LIMIT,
|
||||||
SCROLL_DURATION,
|
SCROLL_DURATION,
|
||||||
SIMPLE_MODAL_OPTIONS
|
SIMPLE_MODAL_OPTIONS,
|
||||||
|
SEARCH_PROGRESS_THROTTLE
|
||||||
} from '../../constants.js'
|
} from '../../constants.js'
|
||||||
import { createHistory } from '../../logic/history.js'
|
import { createHistory } from '../../logic/history.js'
|
||||||
import JSONNode from './JSONNode.svelte'
|
import JSONNode from './JSONNode.svelte'
|
||||||
|
@ -32,7 +33,7 @@ findRootPath
|
||||||
import { keyComboFromEvent } from '../../utils/keyBindings.js'
|
import { keyComboFromEvent } from '../../utils/keyBindings.js'
|
||||||
import { searchAsync, searchNext, searchPrevious, updateSearchResult } from '../../logic/search.js'
|
import { searchAsync, searchNext, searchPrevious, updateSearchResult } from '../../logic/search.js'
|
||||||
import { immutableJSONPatch } from '../../utils/immutableJSONPatch'
|
import { immutableJSONPatch } from '../../utils/immutableJSONPatch'
|
||||||
import { last, initial, cloneDeep, uniqueId } from 'lodash-es'
|
import { last, initial, cloneDeep, uniqueId, throttle } from 'lodash-es'
|
||||||
import jump from '../../assets/jump.js/src/jump.js'
|
import jump from '../../assets/jump.js/src/jump.js'
|
||||||
import { expandPath, syncState, patchProps } from '../../logic/documentState.js'
|
import { expandPath, syncState, patchProps } from '../../logic/documentState.js'
|
||||||
import Menu from './Menu.svelte'
|
import Menu from './Menu.svelte'
|
||||||
|
@ -79,6 +80,8 @@ findRootPath
|
||||||
searchResult = updateSearchResult(doc, results, searchResult)
|
searchResult = updateSearchResult(doc, results, searchResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleSearchProgressDebounced = throttle(handleSearchProgress, SEARCH_PROGRESS_THROTTLE)
|
||||||
|
|
||||||
function handleSearchDone (results) {
|
function handleSearchDone (results) {
|
||||||
searchResult = updateSearchResult(doc, results, searchResult)
|
searchResult = updateSearchResult(doc, results, searchResult)
|
||||||
searching = false
|
searching = false
|
||||||
|
@ -120,7 +123,7 @@ findRootPath
|
||||||
searching = true
|
searching = true
|
||||||
|
|
||||||
searchHandler = searchAsync(searchText, doc, {
|
searchHandler = searchAsync(searchText, doc, {
|
||||||
onProgress: handleSearchProgress,
|
onProgress: handleSearchProgressDebounced,
|
||||||
onDone: handleSearchDone
|
onDone: handleSearchDone
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ export const VALIDATION_ERROR = Symbol('validation:error')
|
||||||
|
|
||||||
export const SCROLL_DURATION = 300 // ms
|
export const SCROLL_DURATION = 300 // ms
|
||||||
export const DEBOUNCE_DELAY = 300
|
export const DEBOUNCE_DELAY = 300
|
||||||
|
export const SEARCH_PROGRESS_THROTTLE = 300 // ms
|
||||||
export const DEFAULT_LIMIT = 100
|
export const DEFAULT_LIMIT = 100
|
||||||
export const MAX_PREVIEW_CHARACTERS = 20e3 // characters
|
export const MAX_PREVIEW_CHARACTERS = 20e3 // characters
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue