Clear messages on application delete

This commit is contained in:
Jannis Mattheis 2018-11-11 20:05:39 +01:00
parent 985c7cf870
commit 887328ee65
2 changed files with 7 additions and 3 deletions

View File

@ -5,6 +5,8 @@ import {action} from 'mobx';
import {SnackReporter} from '../snack/SnackManager'; import {SnackReporter} from '../snack/SnackManager';
export class AppStore extends BaseStore<IApplication> { export class AppStore extends BaseStore<IApplication> {
public onDelete: () => void = () => {};
public constructor(private readonly snack: SnackReporter) { public constructor(private readonly snack: SnackReporter) {
super(); super();
} }
@ -16,9 +18,10 @@ export class AppStore extends BaseStore<IApplication> {
}; };
protected requestDelete = (id: number): Promise<void> => { protected requestDelete = (id: number): Promise<void> => {
return axios return axios.delete(`${config.get('url')}application/${id}`).then(() => {
.delete(`${config.get('url')}application/${id}`) this.onDelete();
.then(() => this.snack('Application deleted')); return this.snack('Application deleted');
});
}; };
@action @action

View File

@ -45,6 +45,7 @@ const initStores = (): StoreMapping => {
const currentUser = new CurrentUser(snackManager.snack); const currentUser = new CurrentUser(snackManager.snack);
const clientStore = new ClientStore(snackManager.snack); const clientStore = new ClientStore(snackManager.snack);
const wsStore = new WebSocketStore(snackManager.snack, currentUser); const wsStore = new WebSocketStore(snackManager.snack, currentUser);
appStore.onDelete = () => messagesStore.clearAll();
return { return {
appStore, appStore,