Slightly refactor lists store
This commit is contained in:
parent
8eff081468
commit
963e163858
|
@ -2,12 +2,12 @@ import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { remove, find } from 'lodash'
|
import { remove, find } from 'lodash'
|
||||||
|
|
||||||
export const defaultState = {
|
export const useListsStore = defineStore('lists', {
|
||||||
|
state: () => ({
|
||||||
allLists: [],
|
allLists: [],
|
||||||
allListsObject: {}
|
allListsObject: {}
|
||||||
}
|
}),
|
||||||
|
getters: {
|
||||||
export const getters = {
|
|
||||||
findListTitle (state) {
|
findListTitle (state) {
|
||||||
return (id) => {
|
return (id) => {
|
||||||
if (!this.allListsObject[id]) return
|
if (!this.allListsObject[id]) return
|
||||||
|
@ -17,9 +17,8 @@ export const getters = {
|
||||||
findListAccounts (state) {
|
findListAccounts (state) {
|
||||||
return (id) => [...this.allListsObject[id].accountIds]
|
return (id) => [...this.allListsObject[id].accountIds]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
actions: {
|
||||||
export const actions = {
|
|
||||||
setLists (value) {
|
setLists (value) {
|
||||||
this.allLists = value
|
this.allLists = value
|
||||||
},
|
},
|
||||||
|
@ -108,9 +107,4 @@ export const actions = {
|
||||||
remove(this.allLists, list => list.id === listId)
|
remove(this.allLists, list => list.id === listId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useListsStore = defineStore('lists', {
|
|
||||||
state: () => (defaultState),
|
|
||||||
getters,
|
|
||||||
actions
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue