Added a timeout for label search
All checks were successful
the build was successful

This commit is contained in:
kolaente 2019-03-06 19:57:48 +01:00
parent 620681063a
commit 95e9b4b905
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -353,6 +353,7 @@
labelService: LabelService,
labelTaskService: LabelTaskService,
foundLabels: [],
labelTimeout: null,
}
},
components: {
@ -523,15 +524,23 @@
return
}
this.labelService.getAll({}, {s: query})
.then(response => {
this.$set(this, 'foundLabels', differenceWith(response, this.taskEditTask.labels, (first, second) => {
return first.id === second.id
}))
})
.catch(e => {
message.error(e, this)
})
if(this.labelTimeout !== null) {
clearTimeout(this.labelTimeout)
}
// Delay the search 300ms to not send a request on every keystroke
this.labelTimeout = setTimeout(() => {
this.labelService.getAll({}, {s: query})
.then(response => {
this.$set(this, 'foundLabels', differenceWith(response, this.taskEditTask.labels, (first, second) => {
return first.id === second.id
}))
this.labelTimeout = null
})
.catch(e => {
message.error(e, this)
})
}, 300)
},
clearAllLabels () {
this.$set(this, 'foundLabels', [])