live updates: remove deleted cards with loadStacks() and not just append them
Signed-off-by: chandi Langecker <git@chandi.it>
This commit is contained in:
committed by
Julius Härtl
parent
41d8867bdd
commit
2e6b20d71d
@@ -273,6 +273,17 @@ export default {
|
|||||||
addNewCard(state, card) {
|
addNewCard(state, card) {
|
||||||
state.cards.push(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: {
|
actions: {
|
||||||
async addCard({ commit }, card) {
|
async addCard({ commit }, card) {
|
||||||
|
|||||||
@@ -84,14 +84,16 @@ export default {
|
|||||||
call = 'loadArchivedStacks'
|
call = 'loadArchivedStacks'
|
||||||
}
|
}
|
||||||
const stacks = await apiClient[call](boardId)
|
const stacks = await apiClient[call](boardId)
|
||||||
|
const cards = []
|
||||||
for (const i in stacks) {
|
for (const i in stacks) {
|
||||||
const stack = stacks[i]
|
const stack = stacks[i]
|
||||||
for (const j in stack.cards) {
|
for (const j in stack.cards) {
|
||||||
commit('addCard', stack.cards[j])
|
cards.push(stack.cards[j])
|
||||||
}
|
}
|
||||||
delete stack.cards
|
delete stack.cards
|
||||||
commit('addStack', stack)
|
commit('addStack', stack)
|
||||||
}
|
}
|
||||||
|
commit('setCards', cards)
|
||||||
},
|
},
|
||||||
createStack({ commit }, stack) {
|
createStack({ commit }, stack) {
|
||||||
stack.boardId = this.state.currentBoard.id
|
stack.boardId = this.state.currentBoard.id
|
||||||
|
|||||||
Reference in New Issue
Block a user