From 64cc9ea72d8742fa0be576fa8d9846fc3e8e5df7 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Mon, 30 Jan 2023 14:27:38 +0100 Subject: [PATCH] fix(ui): fix webhook duplicating --- frontend/app/mstore/settingsStore.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/app/mstore/settingsStore.ts b/frontend/app/mstore/settingsStore.ts index d9dfb0dd3..7dd584fd3 100644 --- a/frontend/app/mstore/settingsStore.ts +++ b/frontend/app/mstore/settingsStore.ts @@ -71,11 +71,16 @@ export default class SettingsStore { return webhookService.saveWebhook(inst) .then(data => { this.webhookInst = new Webhook(data) - this.webhooks = [...this.webhooks, this.webhookInst] + if (inst.webhookId === undefined) this.setWebhooks([...this.webhooks, this.webhookInst]) + else this.setWebhooks([...this.webhooks.filter(hook => hook.webhookId !== data.webhookId), this.webhookInst]) this.hooksLoading = false }) } + setWebhooks = (webhooks: Webhook[]) => { + this.webhooks = webhooks + } + removeWebhook = (hookId: string) => { this.hooksLoading = true return webhookService.removeWebhook(hookId)