Slightly refactor lists store

This commit is contained in:
Sean King 2023-04-06 22:17:03 -06:00
parent 8eff081468
commit 963e163858
No known key found for this signature in database
GPG Key ID: 510C52BACD6E7257
1 changed files with 104 additions and 110 deletions

View File

@ -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
}) })