Webapp: remove assumption from SocketIO job updates

Remove the assumption that a SocketIO job update without "previous state"
set is always an indication that it's about a new job. Soon job priority
will be changeable, and then this assumption will no longer hold.
This commit is contained in:
Sybren A. Stüvel 2022-09-30 16:26:26 +02:00
parent 4176f0e447
commit 0a7b7d9cf6
2 changed files with 10 additions and 16 deletions

@ -150,19 +150,16 @@ export default {
// 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)
.then(() => { this.tabulator.redraw(); }) // Resize columns based on new data.
}
this._refreshAvailableStatuses();
},
processNewJob(jobUpdate) {
if (this.tabulator.initialized) {
this.tabulator.addData([jobUpdate])
.then(this.sortData)
.then(() => { this.tabulator.redraw(); }) // Resize columns based on new data.
}
const row = this.tabulator.rowManager.findRow(jobUpdate.id);
let promise = null;
if (row) promise = this.tabulator.updateData([jobUpdate]);
else promise = this.tabulator.addData([jobUpdate]);
promise
.then(this.sortData)
.then(() => { this.tabulator.redraw(); }) // Resize columns based on new data.
}
this._refreshAvailableStatuses();
},

@ -146,10 +146,7 @@ export default {
this.jobs.setIsJobless(false);
if (this.$refs.jobsTable) {
if (jobUpdate.previous_status)
this.$refs.jobsTable.processJobUpdate(jobUpdate);
else
this.$refs.jobsTable.processNewJob(jobUpdate);
this.$refs.jobsTable.processJobUpdate(jobUpdate);
}
if (this.jobID != jobUpdate.id)
return;