Web: fix race condition where job/task update comes in before table is init

Tabulator can't handle data changes before it's been initialised. If
there is a race condition and a job/task update comes in before that, just
ignore the update.

It might be better to use Vue's `nextTick()` function to defer the update
until Tabulator is ready to receive it, but doing so in a reliable way
might be tricky.
This commit is contained in:
Sybren A. Stüvel 2022-05-20 12:18:40 +02:00
parent 30a30f154b
commit 0a3009d6ed
2 changed files with 12 additions and 4 deletions

View File

@ -123,11 +123,17 @@ export default {
processJobUpdate(jobUpdate) {
// updateData() will only overwrite properties that are actually set on
// jobUpdate, and leave the rest as-is.
if (this.tabulator.initialized) {
this.tabulator.updateData([jobUpdate])
.then(this.sortData);
}
this._refreshAvailableStatuses();
},
processNewJob(jobUpdate) {
if (this.tabulator.initialized) {
this.tabulator.updateData([jobUpdate])
.then(this.sortData);
}
this.tabulator.addData([jobUpdate])
.then(this.sortData);
this._refreshAvailableStatuses();

View File

@ -128,8 +128,10 @@ export default {
processTaskUpdate(taskUpdate) {
// updateData() will only overwrite properties that are actually set on
// taskUpdate, and leave the rest as-is.
if (this.tabulator.initialized) {
this.tabulator.updateData([taskUpdate])
.then(this.sortData);
}
this._refreshAvailableStatuses();
},