Update rest table after item deletion

This commit is contained in:
Melon 2024-06-23 17:32:00 +01:00
parent e278762629
commit 1581a7b810
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 3 additions and 2 deletions

View File

@ -16,7 +16,7 @@ export class RestTable<T extends object> implements IPromiseLike<RestTable<T>> {
this.rows = []; this.rows = [];
} }
private updateSubs() { updateSubs() {
this.subs.forEach(x => x(this)); this.subs.forEach(x => x(this));
} }
@ -82,7 +82,7 @@ export class RestItem<T extends object> implements IPromiseLike<RestItem<T>> {
this.data = data; this.data = data;
} }
private updateSubs() { updateSubs() {
this.subs.forEach(x => x(this)); this.subs.forEach(x => x(this));
} }
@ -138,6 +138,7 @@ export class RestItem<T extends object> implements IPromiseLike<RestItem<T>> {
const x = await LOGIN.clientRequest(this.keyUrl(), options); const x = await LOGIN.clientRequest(this.keyUrl(), options);
if (x.status !== 200) throw new Error("Unexpected status code: " + x.status); if (x.status !== 200) throw new Error("Unexpected status code: " + x.status);
this.table.rows = this.table.rows.filter(x_1 => this.table.keyFunc(x_1.data) !== this.key()); this.table.rows = this.table.rows.filter(x_1 => this.table.keyFunc(x_1.data) !== this.key());
this.table.updateSubs();
this.setLoading(false); this.setLoading(false);
} catch (err) { } catch (err) {
this.setErrorReason("Failed to remove item " + this.key()); this.setErrorReason("Failed to remove item " + this.key());