[#34] Add delete messages action handling
This commit is contained in:
parent
ca5a832baf
commit
e28a157122
|
|
@ -35,13 +35,13 @@ function newMessages(id, data) {
|
||||||
export function deleteMessagesByApp(id) {
|
export function deleteMessagesByApp(id) {
|
||||||
if (id === -1) {
|
if (id === -1) {
|
||||||
axios.delete(config.get('url') + 'message').then(() => {
|
axios.delete(config.get('url') + 'message').then(() => {
|
||||||
dispatcher.dispatch({type: 'DELETE_MESSAGES', id: -1});
|
dispatcher.dispatch({type: 'DELETE_MESSAGES', payload: -1});
|
||||||
snack('Messages deleted');
|
snack('Messages deleted');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
axios.delete(config.get('url') + 'application/' + id + '/message')
|
axios.delete(config.get('url') + 'application/' + id + '/message')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatcher.dispatch({type: 'DELETE_MESSAGES', id});
|
dispatcher.dispatch({type: 'DELETE_MESSAGES', payload: id});
|
||||||
snack('Deleted all messages from the application');
|
snack('Deleted all messages from the application');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,15 @@ class MessageStore extends EventEmitter {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.emit('change');
|
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue