Skip to content

Commit

Permalink
[#34] Add delete messages action handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jmattheis committed Apr 13, 2018
1 parent ca5a832 commit e28a157
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/src/actions/MessageAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function newMessages(id, data) {
export function deleteMessagesByApp(id) {
if (id === -1) {
axios.delete(config.get('url') + 'message').then(() => {
dispatcher.dispatch({type: 'DELETE_MESSAGES', id: -1});
dispatcher.dispatch({type: 'DELETE_MESSAGES', payload: -1});
snack('Messages deleted');
});
} else {
axios.delete(config.get('url') + 'application/' + id + '/message')
.then(() => {
dispatcher.dispatch({type: 'DELETE_MESSAGES', id});
dispatcher.dispatch({type: 'DELETE_MESSAGES', payload: id});
snack('Deleted all messages from the application');
});
}
Expand Down
9 changes: 9 additions & 0 deletions ui/src/stores/MessageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ class MessageStore extends EventEmitter {
}
});
this.emit('change');
} else if (data.type === 'DELETE_MESSAGES') {
const id = data.payload;
if (id === -1) {
this.appToMessages = {};
} else {
delete this.appToMessages[-1];
delete this.appToMessages[id];
}
this.emit('change');
}
}

Expand Down

0 comments on commit e28a157

Please sign in to comment.