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