LP#1855780: avoid race condition when deleting env or params
authorGalen Charlton <gmc@equinoxOLI.org>
Mon, 8 Nov 2021 17:00:42 +0000 (12:00 -0500)
committerJane Sandberg <sandbergja@gmail.com>
Wed, 17 Nov 2021 19:55:11 +0000 (11:55 -0800)
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 <gmc@equinoxOLI.org>
Signed-off-by: Jane Sandberg <sandbergja@gmail.com>
Open-ILS/src/eg2/src/app/staff/admin/local/triggers/trigger-edit.component.ts

index 7d948a3..dcd34e0 100644 (file)
@@ -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();
+                }
             }
         );
     }