From f9d4c2af902988c9d652d31fb8d8de980c4bc991 Mon Sep 17 00:00:00 2001 From: Pranav Raj Sreepuram Date: Thu, 5 Sep 2019 12:30:36 +0530 Subject: [PATCH] [codeclimate] Reduce number of lines in bindEvent --- app/javascript/src/helper/pusher.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/app/javascript/src/helper/pusher.js b/app/javascript/src/helper/pusher.js index d7ed27d90..d44f74a81 100644 --- a/app/javascript/src/helper/pusher.js +++ b/app/javascript/src/helper/pusher.js @@ -25,10 +25,8 @@ class VuePusher { this.pusher.unsubscribe(channelName); } - // eslint-disable-next-line bindEvent(channel) { channel.bind('message.created', data => { - // Play sound if incoming if (!data.message_type) { new Audio(ding).play(); } @@ -44,25 +42,15 @@ class VuePusher { }); channel.bind('assignee.changed', payload => { - const { meta } = payload; - if (!meta) return; - const { assignee } = meta; - const { id } = payload; + const { meta = {}, id } = payload; + const { assignee } = meta || {}; if (id) { - this.app.$store.dispatch('updateAssignee', { - id, - assignee, - }); + this.app.$store.dispatch('updateAssignee', { id, assignee }); } }); - channel.bind('user:logout', () => { - AuthAPI.logout(); - }); - - channel.bind('page:reload', () => { - window.location.reload(); - }); + channel.bind('user:logout', () => AuthAPI.logout()); + channel.bind('page:reload', () => window.location.reload()); } }