From 240d262db3ab073a6ce75acc4f365e48530146a8 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Sun, 13 Aug 2017 17:18:45 +0100 Subject: [PATCH] Only starts autosave if user is logged in --- app/assets/javascripts/autosave.js | 5 ++++- .../javascripts/notes/components/issue_comment_form.vue | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/autosave.js b/app/assets/javascripts/autosave.js index 7db696159bc..4d2d4db7c0e 100644 --- a/app/assets/javascripts/autosave.js +++ b/app/assets/javascripts/autosave.js @@ -35,7 +35,10 @@ window.Autosave = (function() { // v-model does not update with jQuery trigger // https://github.com/vuejs/vue/issues/2804#issuecomment-216968137 const event = new Event('change', { bubbles: true, cancelable: false }); - this.field.get(0).dispatchEvent(event); + const field = this.field.get(0); + if (field) { + field.dispatchEvent(event); + } } }; diff --git a/app/assets/javascripts/notes/components/issue_comment_form.vue b/app/assets/javascripts/notes/components/issue_comment_form.vue index 259644b13a4..816db03230c 100644 --- a/app/assets/javascripts/notes/components/issue_comment_form.vue +++ b/app/assets/javascripts/notes/components/issue_comment_form.vue @@ -184,7 +184,9 @@ } }, initAutoSave() { - this.autosave = new Autosave($(this.$refs.textarea), ['Note', 'Issue', this.getIssueData.id], 'issue'); + if (this.isLoggedIn) { + this.autosave = new Autosave($(this.$refs.textarea), ['Note', 'Issue', this.getIssueData.id], 'issue'); + } }, initTaskList() { return new TaskList({