feature/projects-all-the-way-down #3323
|
@ -36,8 +36,8 @@ export const useProjectStore = defineStore('project', () => {
|
|||
.filter(p => !p.isArchived && p.isFavorite))
|
||||
const hasProjects = computed(() => projects.value ? true : false)
|
||||
|
||||
|
||||
const getChildProjects = computed(() => {
|
||||
return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id) || []
|
||||
const getChildProjects = computed<IProject[]>(() => {
|
||||
dpschen
commented
This computed seems really unnecessary. Reason: We can achieve the same (and faster) by using:
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])
```
konrad
commented
We've actually been using computed for most uses of the store computed anyway. I've changed it to use the 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
dpschen
commented
The fallback is unnecessary OR the type of the projects ref is wrong. Because The fallback is unnecessary OR the type of the projects ref is wrong. Because `Object.values` on an object should always return an array.
konrad
commented
The type is correct. I've removed the fallback. The type is correct. I've removed the fallback.
dpschen
commented
The new type on the computed is wrong. The computed returns a function that returns 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.
konrad
commented
Should be fixed now. Should be fixed now.
|
||||
|
|
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:
Fixed.