diff --git a/src/store/card.js b/src/store/card.js index a57ba13a0..21c0e299a 100644 --- a/src/store/card.js +++ b/src/store/card.js @@ -273,6 +273,17 @@ export default { addNewCard(state, card) { state.cards.push(card) }, + setCards(state, cards) { + const deletedCards = state.cards.filter(_card => { + return cards.findIndex(c => _card.id === c.id) === -1 + }) + for (const card of deletedCards) { + this.commit('deleteCard', card) + } + for (const card of cards) { + this.commit('addCard', card) + } + }, }, actions: { async addCard({ commit }, card) { diff --git a/src/store/stack.js b/src/store/stack.js index f55d6211d..608ffd32b 100644 --- a/src/store/stack.js +++ b/src/store/stack.js @@ -84,14 +84,16 @@ export default { call = 'loadArchivedStacks' } const stacks = await apiClient[call](boardId) + const cards = [] for (const i in stacks) { const stack = stacks[i] for (const j in stack.cards) { - commit('addCard', stack.cards[j]) + cards.push(stack.cards[j]) } delete stack.cards commit('addStack', stack) } + commit('setCards', cards) }, createStack({ commit }, stack) { stack.boardId = this.state.currentBoard.id