From f7e96d742e64d89e7aaa71d83c79beaf65bf3b77 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 8 Nov 2021 12:00:42 -0500 Subject: [PATCH] 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 --- .../src/app/staff/admin/local/triggers/trigger-edit.component.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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(); + } } ); } -- 2.11.0