feature/projects-all-the-way-down #3323

Merged
konrad merged 123 commits from feature/projects-all-the-way-down into main 2023-05-30 10:09:40 +00:00
Showing only changes of commit a2cc9ddc88 - Show all commits

View File

@ -34,7 +34,7 @@ export const useProjectStore = defineStore('project', () => {
.filter(p => p.parentProjectId === 0 && !p.isArchived))
const favoriteProjects = computed(() => projectsArray.value
.filter(p => !p.isArchived && p.isFavorite))
const hasProjects = computed(() => projects.value ? true : false)
const hasProjects = computed(() => projectsArray.value.length > 0)

Since projects is of type object (defined by its type) this shouldn't work because !!{} === true.
Even if it would be undefined or null sometimes this should use Boolean(projects.value) for clarity instead.

Afaik there is no way around something like:

computed(() => Boolean(projectsArray.value.length))
Since `projects` is of type object (defined by its type) this shouldn't work because `!!{} === true`. Even if it would be undefined or null sometimes this should use `Boolean(projects.value)` for clarity instead. Afaik there is no way around something like: ```ts computed(() => Boolean(projectsArray.value.length)) ```

Fixed.

Fixed.
const getChildProjects = computed<IProject[]>(() => {

This computed seems really unnecessary. Reason: We can achieve the same (and faster) by using: projects.value[id]. Since projects is exported we should replace uses of this computed. We might need to create new simple computeds where used. Depending on usecase something like

const myProject = computed(() => projects.value[myProjectId.value])
This computed seems really unnecessary. Reason: We can achieve the same (and faster) by using: `projects.value[id]`. Since `projects` is exported we should replace uses of this computed. We might need to create new simple computeds where used. Depending on usecase something like ```ts const myProject = computed(() => projects.value[myProjectId.value]) ```

We've actually been using computed for most uses of the store computed anyway. I've changed it to use the projects property of the store directly.

We've actually been using computed for most uses of the store computed anyway. I've changed it to use the `projects` property of the store directly.
return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id)