Skip to content

Commit 21ce3db

Browse files
authored
Merge pull request #8141 from nextcloud/refactor/pinia-migration-overviewStore
refactor(pinia): move overview store to pinia
2 parents 4097bb6 + 131be95 commit 21ce3db

4 files changed

Lines changed: 41 additions & 55 deletions

File tree

src/components/overview/Overview.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
<script>
4545
import Controls from '../Controls.vue'
4646
import CardItem from '../cards/CardItem.vue'
47-
import { mapGetters } from 'vuex'
4847
import GlobalSearchResults from '../search/GlobalSearchResults.vue'
48+
import { useOverviewStore } from '../../stores/overview.js'
49+
import { mapActions, mapState } from 'pinia'
4950
5051
const FILTER_UPCOMING = 'upcoming'
5152
@@ -112,7 +113,7 @@ export default {
112113
return ''
113114
}
114115
},
115-
...mapGetters(['assignedCardsDashboard']),
116+
...mapState(useOverviewStore, ['assignedCards']),
116117
},
117118
watch: {
118119
'$route.params.filter'() {
@@ -123,19 +124,20 @@ export default {
123124
this.getData()
124125
},
125126
methods: {
127+
...mapActions(useOverviewStore, ['loadUpcoming']),
126128
async getData() {
127129
this.loading = true
128130
try {
129131
if (this.filter === FILTER_UPCOMING) {
130-
await this.$store.dispatch('loadUpcoming')
132+
await this.loadUpcoming()
131133
}
132134
} catch (e) {
133135
console.error(e)
134136
}
135137
this.loading = false
136138
},
137139
filterCards(when) {
138-
return this.assignedCardsDashboard[when]
140+
return this.assignedCards[when]
139141
},
140142
sortCards(cards) {
141143
if (!cards) {

src/store/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { BoardApi } from '../services/BoardApi.js'
1414
import stackModuleFactory from './stack.js'
1515
import cardModuleFactory from './card.js'
1616
import attachment from './attachment.js'
17-
import overview from './overview.js'
1817
Vue.use(Vuex)
1918

2019
const apiClient = new BoardApi()
@@ -35,7 +34,6 @@ export default function storeFactory() {
3534
stack: stackModuleFactory(),
3635
card: cardModuleFactory(),
3736
attachment,
38-
overview,
3937
},
4038
strict: debug,
4139
state: {

src/store/overview.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/stores/overview.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { defineStore } from 'pinia'
7+
import { OverviewApi } from '../services/OverviewApi.js'
8+
9+
const overviewApi = new OverviewApi()
10+
11+
export const useOverviewStore = defineStore('overview', {
12+
state: () => ({
13+
assignedCards: [],
14+
loading: false,
15+
}),
16+
actions: {
17+
async loadUpcoming() {
18+
if (this.loading) {
19+
return this.loading
20+
}
21+
const promise = (async () => {
22+
this.$vuex.commit('setCurrentBoard', null)
23+
const assignedCards = await overviewApi.get('upcoming')
24+
const assignedCardsFlat = Object.values(assignedCards).flat()
25+
for (const i in assignedCardsFlat) {
26+
this.$vuex.commit('addCard', assignedCardsFlat[i])
27+
}
28+
this.assignedCards = assignedCards
29+
this.loading = false
30+
})()
31+
this.loading = promise
32+
return promise
33+
},
34+
},
35+
})

0 commit comments

Comments
 (0)