mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
add debounce for search, increase the timer for fulltext updates (#5844)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
c526365e4d
commit
ece0504d3c
@ -1287,26 +1287,16 @@ export class LiveQuery implements WithTx, Client {
|
||||
return result
|
||||
}
|
||||
|
||||
triggerCounter = 0
|
||||
searchTriggerTimer: any
|
||||
triggerInProgress = true
|
||||
|
||||
private async checkUpdateEvents (evt: TxWorkspaceEvent, trigger = true): Promise<void> {
|
||||
clearTimeout(this.searchTriggerTimer)
|
||||
|
||||
// We need to add trigger once more, since elastic could have a huge lag with document availability.
|
||||
if (trigger || this.triggerCounter > 0) {
|
||||
if (trigger) {
|
||||
this.triggerCounter = 2 // Schedule 2 refreshes on every 10 seconds.
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.triggerCounter--
|
||||
void this.checkUpdateEvents(evt, false)
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
if (this.triggerInProgress) {
|
||||
this.triggerInProgress = false
|
||||
const h = this.client.getHierarchy()
|
||||
function hasClass (q: Query, classes: Ref<Class<Doc>>[]): boolean {
|
||||
return classes.includes(q._class) || classes.some((it) => h.isDerived(q._class, it) || h.isDerived(it, q._class))
|
||||
return (
|
||||
classes.includes(q._class) || classes.some((it) => h.isDerived(q._class, it) || h.isDerived(it, q._class))
|
||||
)
|
||||
}
|
||||
if (evt.event === WorkspaceEvent.IndexingUpdate) {
|
||||
const indexingParam = evt.params as IndexingUpdateEvent
|
||||
@ -1371,6 +1361,11 @@ export class LiveQuery implements WithTx, Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.triggerInProgress = true
|
||||
void this.checkUpdateEvents(evt, false)
|
||||
}, 20000)
|
||||
}
|
||||
}
|
||||
|
||||
private async changePrivateHandler (evt: TxWorkspaceEvent): Promise<void> {
|
||||
|
@ -295,6 +295,15 @@
|
||||
$: void translate(view.string.ActionPlaceholder, {}).then((res) => {
|
||||
phTraslate = res
|
||||
})
|
||||
let timer: any
|
||||
$: _search = search
|
||||
function restartTimer (): void {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
search = _search
|
||||
dispatch('change', _search)
|
||||
}, 500)
|
||||
}
|
||||
</script>
|
||||
|
||||
<ActionContext
|
||||
@ -364,10 +373,14 @@
|
||||
class="actionsInput"
|
||||
bind:this={textHTML}
|
||||
type="text"
|
||||
bind:value={search}
|
||||
bind:value={_search}
|
||||
placeholder={phTraslate}
|
||||
on:change
|
||||
on:input
|
||||
on:change={() => {
|
||||
restartTimer()
|
||||
}}
|
||||
on:input={() => {
|
||||
restartTimer()
|
||||
}}
|
||||
on:keydown
|
||||
/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user