From 887328ee650711471ce55ddddebb81891dab864a Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sun, 11 Nov 2018 20:05:39 +0100 Subject: [PATCH] Clear messages on application delete --- ui/src/application/AppStore.ts | 9 ++++++--- ui/src/index.tsx | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/src/application/AppStore.ts b/ui/src/application/AppStore.ts index 8b35d41..f58cbfa 100644 --- a/ui/src/application/AppStore.ts +++ b/ui/src/application/AppStore.ts @@ -5,6 +5,8 @@ import {action} from 'mobx'; import {SnackReporter} from '../snack/SnackManager'; export class AppStore extends BaseStore { + public onDelete: () => void = () => {}; + public constructor(private readonly snack: SnackReporter) { super(); } @@ -16,9 +18,10 @@ export class AppStore extends BaseStore { }; protected requestDelete = (id: number): Promise => { - return axios - .delete(`${config.get('url')}application/${id}`) - .then(() => this.snack('Application deleted')); + return axios.delete(`${config.get('url')}application/${id}`).then(() => { + this.onDelete(); + return this.snack('Application deleted'); + }); }; @action diff --git a/ui/src/index.tsx b/ui/src/index.tsx index c2ff8df..10604f1 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -45,6 +45,7 @@ const initStores = (): StoreMapping => { const currentUser = new CurrentUser(snackManager.snack); const clientStore = new ClientStore(snackManager.snack); const wsStore = new WebSocketStore(snackManager.snack, currentUser); + appStore.onDelete = () => messagesStore.clearAll(); return { appStore,