diff options
Diffstat (limited to 'app/assets/javascripts/sidebar/components')
-rw-r--r-- | app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js index e2dba1fb0c2..244b67b3ad9 100644 --- a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js +++ b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js @@ -17,15 +17,21 @@ export default { }, methods: { listenForSlashCommands() { - $(document).on('ajax:success', '.gfm-form', (e, data) => { - const subscribedCommands = ['spend_time', 'time_estimate']; - const changedCommands = data.commands_changes + $(document).on('ajax:success', '.gfm-form', this.slashCommandListened); + }, + slashCommandListened(e, data) { + const subscribedCommands = ['spend_time', 'time_estimate']; + let changedCommands; + if (data !== undefined) { + changedCommands = data.commands_changes ? Object.keys(data.commands_changes) : []; - if (changedCommands && _.intersection(subscribedCommands, changedCommands).length) { - this.mediator.fetch(); - } - }); + } else { + changedCommands = []; + } + if (changedCommands && _.intersection(subscribedCommands, changedCommands).length) { + this.mediator.fetch(); + } }, }, mounted() { |