[codeclimate] Reduce number of lines in bindEvent

This commit is contained in:
Pranav Raj Sreepuram 2019-09-05 12:30:36 +05:30
parent a108ae7789
commit f9d4c2af90

View file

@ -25,10 +25,8 @@ class VuePusher {
this.pusher.unsubscribe(channelName); this.pusher.unsubscribe(channelName);
} }
// eslint-disable-next-line
bindEvent(channel) { bindEvent(channel) {
channel.bind('message.created', data => { channel.bind('message.created', data => {
// Play sound if incoming
if (!data.message_type) { if (!data.message_type) {
new Audio(ding).play(); new Audio(ding).play();
} }
@ -44,25 +42,15 @@ class VuePusher {
}); });
channel.bind('assignee.changed', payload => { channel.bind('assignee.changed', payload => {
const { meta } = payload; const { meta = {}, id } = payload;
if (!meta) return; const { assignee } = meta || {};
const { assignee } = meta;
const { id } = payload;
if (id) { if (id) {
this.app.$store.dispatch('updateAssignee', { this.app.$store.dispatch('updateAssignee', { id, assignee });
id,
assignee,
});
} }
}); });
channel.bind('user:logout', () => { channel.bind('user:logout', () => AuthAPI.logout());
AuthAPI.logout(); channel.bind('page:reload', () => window.location.reload());
});
channel.bind('page:reload', () => {
window.location.reload();
});
} }
} }