Vuex: Run overview#loadUpcoming only once
needed for dashboard widgets Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
committed by
Julius Härtl
parent
515d9cbd65
commit
a37e7192aa
@@ -29,6 +29,7 @@ const apiClient = new OverviewApi()
|
|||||||
export default {
|
export default {
|
||||||
state: {
|
state: {
|
||||||
assignedCards: [],
|
assignedCards: [],
|
||||||
|
loading: false,
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
assignedCardsDashboard: state => {
|
assignedCardsDashboard: state => {
|
||||||
@@ -39,18 +40,27 @@ export default {
|
|||||||
setAssignedCards(state, assignedCards) {
|
setAssignedCards(state, assignedCards) {
|
||||||
state.assignedCards = assignedCards
|
state.assignedCards = assignedCards
|
||||||
},
|
},
|
||||||
|
setLoading(state, promise) {
|
||||||
|
state.loading = promise
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async loadUpcoming({ commit }) {
|
async loadUpcoming({ state, commit }) {
|
||||||
commit('setCurrentBoard', null)
|
if (state.loading) {
|
||||||
const upcommingCards = await apiClient.get('upcoming')
|
return state.loading
|
||||||
|
|
||||||
for (const dueStatus in upcommingCards) {
|
|
||||||
for (const idx in upcommingCards[dueStatus]) {
|
|
||||||
commit('addCard', upcommingCards[dueStatus][idx])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
commit('setAssignedCards', upcommingCards)
|
const promise = (async () => {
|
||||||
|
commit('setCurrentBoard', null)
|
||||||
|
const assignedCards = await apiClient.get('upcoming')
|
||||||
|
const assignedCardsFlat = assignedCards.flat()
|
||||||
|
for (const i in assignedCardsFlat) {
|
||||||
|
commit('addCard', assignedCardsFlat[i])
|
||||||
|
}
|
||||||
|
commit('setAssignedCards', assignedCardsFlat)
|
||||||
|
commit('setLoading', false)
|
||||||
|
})()
|
||||||
|
commit('setLoading', promise)
|
||||||
|
return promise
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user