Web: respond to worker updates that indicate a worker was removed

The code isn't the prettiest, but it works ;-)
This commit is contained in:
Sybren A. Stüvel 2022-08-11 17:45:12 -07:00
parent 6122f14cbc
commit b4194e32e9
2 changed files with 20 additions and 9 deletions

View File

@ -137,17 +137,23 @@ export default {
const existingRow = this.tabulator.rowManager.findRow(workerUpdate.id);
let promise;
// TODO: clean up the code below:
if (existingRow) {
// Tabbulator doesn't update ommitted fields, but if `status_change`
// is ommitted it means "no status change requested"; this should still
// force an update of the `status_change` field.
if (!workerUpdate.status_change) {
workerUpdate.status_change = null;
if (workerUpdate.deleted_at) {
// This is a deletion, not a regular update.
promise = existingRow.delete();
} else {
// Tabbulator doesn't update ommitted fields, but if `status_change`
// is ommitted it means "no status change requested"; this should still
// force an update of the `status_change` field.
if (!workerUpdate.status_change) {
workerUpdate.status_change = null;
}
promise = this.tabulator.updateData([workerUpdate]);
// Tabulator doesn't know we're using 'status_change' in the 'status'
// column, so it also won't know to redraw when that field changes.
promise.then(() => existingRow.reinitialize(true));
}
promise = this.tabulator.updateData([workerUpdate]);
// Tabulator doesn't know we're using 'status_change' in the 'status'
// column, so it also won't know to redraw when that field changes.
promise.then(() => existingRow.reinitialize(true));
} else {
promise = this.tabulator.addData([workerUpdate]);
}

View File

@ -78,6 +78,11 @@ export default {
if (this.workerID != workerUpdate.id)
return;
if (workerUpdate.deleted_at) {
this._routeToWorker("");
return;
}
this._fetchWorker(this.workerID);
},