1
0

fix(projects): load all projects when first opening Vikunja

This commit is contained in:
kolaente
2024-03-02 13:43:04 +01:00
parent a3932a0a19
commit 89b01e86bc
5 changed files with 22 additions and 14 deletions

View File

@ -175,20 +175,28 @@ export const useProjectStore = defineStore('project', () => {
}
}
async function loadProjects() {
async function loadAllProjects() {
const cancel = setModuleLoading(setIsLoading)
const projectService = new ProjectService()
const loadedProjects: IProject[] = []
let page = 1
try {
const loadedProjects = await projectService.getAll({}, {is_archived: true}) as IProject[]
projects.value = {}
setProjects(loadedProjects)
loadedProjects.forEach(p => add(p))
return loadedProjects
do {
const newProjects = await projectService.getAll({}, {is_archived: true}, page) as IProject[]
loadedProjects.push(...newProjects)
page++
} while (page <= projectService.totalPages)
} finally {
cancel()
}
projects.value = {}
setProjects(loadedProjects)
loadedProjects.forEach(p => add(p))
return loadedProjects
}
function getAncestors(project: IProject): IProject[] {
@ -222,7 +230,7 @@ export const useProjectStore = defineStore('project', () => {
setProjects,
removeProjectById,
toggleProjectFavorite,
loadProjects,
loadAllProjects,
createProject,
updateProject,
deleteProject,

View File

@ -473,7 +473,7 @@ export const useTaskStore = defineStore('task', () => {
task = await taskService.update(task)
// reloading the projects list so that the Favorites project shows up or is hidden when there are (or are not) favorite tasks
await projectStore.loadProjects()
await projectStore.loadAllProjects()
return task
}