From 23552b2b1b822601bb1d1effc74c9814986a00fd Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 28 Jan 2021 19:29:50 +0100 Subject: [PATCH] Fix attachments being added mutliple times --- src/components/tasks/mixins/attachmentUpload.js | 2 +- src/store/modules/attachments.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/tasks/mixins/attachmentUpload.js b/src/components/tasks/mixins/attachmentUpload.js index d08226f86..798547aab 100644 --- a/src/components/tasks/mixins/attachmentUpload.js +++ b/src/components/tasks/mixins/attachmentUpload.js @@ -14,10 +14,10 @@ export default { const attachmentModel = new AttachmentModel({taskId: this.taskId}) attachmentService.create(attachmentModel, files) .then(r => { + console.debug(`Uploaded attachments for task ${this.taskId}, response was`, r) if (r.success !== null) { r.success.forEach(a => { this.$store.commit('attachments/removeById', a.id) - this.$store.commit('attachments/add', a) this.$store.dispatch('tasks/addTaskAttachment', { taskId: this.taskId, attachment: a, diff --git a/src/store/modules/attachments.js b/src/store/modules/attachments.js index 871780923..32e8dd725 100644 --- a/src/store/modules/attachments.js +++ b/src/store/modules/attachments.js @@ -7,15 +7,18 @@ export default { }), mutations: { set(state, attachments) { + console.debug('Set attachments', attachments) Vue.set(state, 'attachments', attachments) }, add(state, attachment) { + console.debug('Add attachement', attachment) state.attachments.push(attachment) }, removeById(state, id) { for (const a in state.attachments) { if (state.attachments[a].id === id) { state.attachments.splice(a, 1) + console.debug('Remove attachement', id) break } }