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 d414b65e7d - Show all commits

View File

@ -36,8 +36,8 @@ export const useProjectStore = defineStore('project', () => {
.filter(p => !p.isArchived && p.isFavorite))
const hasProjects = computed(() => projects.value ? true : false)

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(() => {
return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id) || []
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)
})
const findProjectByExactname = computed(() => {
konrad marked this conversation as resolved Outdated

The fallback is unnecessary OR the type of the projects ref is wrong. Because Object.values on an object should always return an array.

The fallback is unnecessary OR the type of the projects ref is wrong. Because `Object.values` on an object should always return an array.

The type is correct. I've removed the fallback.

The type is correct. I've removed the fallback.

The new type on the computed is wrong. The computed returns a function that returns IProject[]. So the correct type is probably (id: IProject['id']) => IProject[].

But that should be automatically inferred by the returned function. If it is not inferreed, annotate the returned function instead and remove the type annotation of the computed.

The new type on the computed is wrong. The computed returns a function that returns `IProject[]`. So the correct type is probably `(id: IProject['id']) => IProject[]`. But that should be automatically inferred by the returned function. If it is not inferreed, annotate the returned function instead and remove the type annotation of the computed.

Should be fixed now.

Should be fixed now.