From 8f77aa005dd7863f750c9511e93ee8502306be14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 22 Jun 2020 20:31:24 +0200 Subject: [PATCH] Fix fetching attachments on card change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/card/AttachmentList.vue | 5 ----- src/components/card/CardSidebarTabAttachments.vue | 5 +++++ src/store/attachment.js | 6 +----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/card/AttachmentList.vue b/src/components/card/AttachmentList.vue index c6a05c7f8..9a430afb7 100644 --- a/src/components/card/AttachmentList.vue +++ b/src/components/card/AttachmentList.vue @@ -83,11 +83,6 @@ export default { required: false, }, }, - data() { - return { - - } - }, computed: { attachments() { return [...this.$store.getters.attachmentsByCard(this.cardId)].sort((a, b) => b.id - a.id) diff --git a/src/components/card/CardSidebarTabAttachments.vue b/src/components/card/CardSidebarTabAttachments.vue index 09adb140d..3d0e9261d 100644 --- a/src/components/card/CardSidebarTabAttachments.vue +++ b/src/components/card/CardSidebarTabAttachments.vue @@ -114,6 +114,11 @@ export default { return this.card.id }, }, + watch: { + card(newCard) { + this.$store.dispatch('fetchAttachments', newCard.id) + }, + }, created: function() { this.$store.dispatch('fetchAttachments', this.card.id) }, diff --git a/src/store/attachment.js b/src/store/attachment.js index 8376adf95..ad696ba12 100644 --- a/src/store/attachment.js +++ b/src/store/attachment.js @@ -48,11 +48,7 @@ export default { }, createAttachments(state, { cardId, attachments }) { - if (typeof state.attachments[cardId] === 'undefined') { - Vue.set(state.attachments, cardId, attachments) - } else { - state.attachments[cardId].push(attachments) - } + Vue.set(state.attachments, cardId, attachments) }, updateAttachment(state, { cardId, attachment }) {