feature/projects-all-the-way-down #3323
|
@ -29,6 +29,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 hasProjects = computed(() => projects.value ? true : false)
|
||||
|
||||
const getProjectById = computed(() => {
|
||||
return (id: IProject['id']) => typeof projects.value[id] !== 'undefined' ? projects.value[id] : null
|
||||
|
@ -181,6 +182,7 @@ export const useProjectStore = defineStore('project', () => {
|
|||
isLoading: readonly(isLoading),
|
||||
projects: readonly(projects),
|
||||
projectsArray: readonly(projectsArray),
|
||||
hasProjects: readonly(hasProjects),
|
||||
|
||||
getProjectById,
|
||||
findProjectByExactname,
|
||||
|
|
|
@ -80,7 +80,7 @@ const projectHistory = computed(() => {
|
|||
|
||||
const migratorsEnabled = computed(() => configStore.availableMigrators?.length > 0)
|
||||
const hasTasks = computed(() => baseStore.hasTasks)
|
||||
const hasProjects = computed(() => projectStore.projects ? true : false)
|
||||
const hasProjects = computed(() => projectStore.hasProjects)
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
const loading = computed(() => taskStore.isLoading)
|
||||
const deletionScheduledAt = computed(() => parseDateOrNull(authStore.info?.deletionScheduledAt))
|
||||
|
||||
|
|
Reference in New Issue
Block a user
This should be a computed of the store, like
hasTasks
.Shouldn't we check the length here (
projectStore.projects?.length
)?projects
is an object, so checking the length of it won't work.Moved it to the store.
Then
Object.keys?.length
Wouldn't that cause a call to
Object.keys
? I think my solution is faster.Checked it: https://jsbench.me/hslfseq93y/1
Using
Object.keys
really is slower, and by a lot.True. Using a Map with size would probably be the perfect solution here. But that is something for another time.
Don't wrap computed in computed. use
projectStore.hasProjects
directlyDone