diff --git a/modules/ui/src/app/pages/devices/devices.store.ts b/modules/ui/src/app/pages/devices/devices.store.ts index 282275f7d..7145aabca 100644 --- a/modules/ui/src/app/pages/devices/devices.store.ts +++ b/modules/ui/src/app/pages/devices/devices.store.ts @@ -66,9 +66,11 @@ export class DevicesStore extends ComponentStore { exhaustMap(({ device, onDelete }) => { return this.testRunService.deleteDevice(device).pipe( withLatestFrom(this.devices$), - tap(([, devices]) => { - this.removeDevice(device, devices); - onDelete(); + tap(([deleted, devices]) => { + if (deleted) { + this.removeDevice(device, devices); + onDelete(); + } }) ); }) @@ -81,9 +83,11 @@ export class DevicesStore extends ComponentStore { exhaustMap(({ device, onSuccess }) => { return this.testRunService.saveDevice(device).pipe( withLatestFrom(this.devices$), - tap(([, devices]) => { - this.addDevice(device, devices); - onSuccess(); + tap(([added, devices]) => { + if (added) { + this.addDevice(device, devices); + onSuccess(); + } }) ); }) @@ -100,9 +104,11 @@ export class DevicesStore extends ComponentStore { exhaustMap(({ device, mac_addr, onSuccess }) => { return this.testRunService.editDevice(device, mac_addr).pipe( withLatestFrom(this.devices$), - tap(([, devices]) => { - this.updateDevice(device, mac_addr, devices); - onSuccess(); + tap(([edited, devices]) => { + if (edited) { + this.updateDevice(device, mac_addr, devices); + onSuccess(); + } }) ); }) diff --git a/modules/ui/src/app/services/test-run.service.ts b/modules/ui/src/app/services/test-run.service.ts index eb44cd631..5620f9404 100644 --- a/modules/ui/src/app/services/test-run.service.ts +++ b/modules/ui/src/app/services/test-run.service.ts @@ -130,7 +130,10 @@ export class TestRunService { saveDevice(device: Device): Observable { return this.http .post(`${API_URL}/device`, JSON.stringify(device)) - .pipe(map(() => true)); + .pipe( + map(() => true), + catchError(() => of(false)) + ); } editDevice(device: Device, mac_addr: string): Observable { @@ -145,14 +148,20 @@ export class TestRunService { return this.http .post(`${API_URL}/device/edit`, JSON.stringify(request)) - .pipe(map(() => true)); + .pipe( + map(() => true), + catchError(() => of(false)) + ); } deleteDevice(device: Device): Observable { return this.http .delete(`${API_URL}/device`, { body: JSON.stringify(device), }) - .pipe(map(() => true)); + .pipe( + map(() => true), + catchError(() => of(false)) + ); } getHistory(): Observable {