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';
export class AppStore extends BaseStore<IApplication> {
public onDelete: () => void = () => {};
public constructor(private readonly snack: SnackReporter) {
super();
}
@ -16,9 +18,10 @@ export class AppStore extends BaseStore<IApplication> {
};
protected requestDelete = (id: number): Promise<void> => {
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

View File

@ -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,