From: Galen Charlton Date: Mon, 8 Nov 2021 17:00:42 +0000 (-0500) Subject: LP#1855780: avoid race condition when deleting env or params X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f7e96d742e64d89e7aaa71d83c79beaf65bf3b77;p=Evergreen.git LP#1855780: avoid race condition when deleting env or params When deleting from a grid using pcrud.autoApply, the grid should be refreshed only at the very end. Otherwise, even if you're deleting only one row, the grid reload could occur before the deletion is committed, yielding a grid fetch error when pcrud complains about verifying access to a row that is no longer in the database. Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/triggers/trigger-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/triggers/trigger-edit.component.ts index 7d948a33e7..dcd34e05ae 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/triggers/trigger-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/triggers/trigger-edit.component.ts @@ -120,16 +120,22 @@ export class EditEventDefinitionComponent implements OnInit { currentGrid = this.paramGrid; } idlThings.forEach(idlThing => idlThing.isdeleted(true)); + let _deleted = 0; this.pcrud.autoApply(idlThings).subscribe( val => { console.debug('deleted: ' + val); this.deleteSuccessString.current() .then(str => this.toast.success(str)); - currentGrid.reload(); + _deleted++; }, err => { this.deleteFailedString.current() .then(str => this.toast.danger(str)); + }, + () => { + if (_deleted > 0) { + currentGrid.reload(); + } } ); }