chore: export projects as array directly from projects store
This commit is contained in:
parent
2bb7ff1803
commit
e4379f0a22
@ -79,10 +79,10 @@ onBeforeMount(async () => {
|
||||
await projectStore.loadProjects()
|
||||
})
|
||||
|
||||
const projects = computed(() => Object.values(projectStore.projects)
|
||||
const projects = computed(() => projectStore.projectsArray
|
||||
.filter(p => p.parentProjectId === 0 && !p.isArchived)
|
||||
.sort((a, b) => a.position < b.position ? -1 : 1))
|
||||
const favoriteProjects = computed(() => Object.values(projectStore.projects)
|
||||
const favoriteProjects = computed(() => projectStore.projectsArray
|
||||
.filter(p => !p.isArchived && p.isFavorite)
|
||||
.map(p => ({
|
||||
...p,
|
||||
|
@ -28,7 +28,7 @@ export const useProjectStore = defineStore('project', () => {
|
||||
|
||||
// The projects are stored as an object which has the project ids as keys.
|
||||
const projects = ref<ProjectState>({})
|
||||
|
||||
const projectsArray = computed(() => Object.values(projects.value))
|
||||
|
||||
const getProjectById = computed(() => {
|
||||
return (id: IProject['id']) => typeof projects.value[id] !== 'undefined' ? projects.value[id] : null
|
||||
@ -180,6 +180,7 @@ export const useProjectStore = defineStore('project', () => {
|
||||
return {
|
||||
isLoading: readonly(isLoading),
|
||||
projects: readonly(projects),
|
||||
projectsArray: readonly(projectsArray),
|
||||
|
||||
getProjectById,
|
||||
findProjectByExactname,
|
||||
|
@ -91,7 +91,7 @@ const showArchived = useStorage('showArchived', false)
|
||||
|
||||
const loading = computed(() => projectStore.isLoading)
|
||||
const projects = computed(() => {
|
||||
return Object.values(projectStore.projects).filter(project => showArchived.value
|
||||
return projectStore.projectsArray.filter(project => showArchived.value
|
||||
? true
|
||||
: !project.isArchived,
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user