From 600c148bb13c037d7bb974e14a63ba28bc321a78 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 28 Mar 2023 14:03:41 +0200 Subject: [PATCH] fix(navigation): make sure the Favorites project shows up when marking or unmarking a task as favorite --- cypress/e2e/task/task.spec.ts | 4 ++-- src/components/tasks/partials/singleTaskInProject.vue | 1 + src/stores/projects.ts | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/task/task.spec.ts b/cypress/e2e/task/task.spec.ts index 5f03c4fee..521a91e2e 100644 --- a/cypress/e2e/task/task.spec.ts +++ b/cypress/e2e/task/task.spec.ts @@ -100,14 +100,14 @@ describe('Task', () => { .should('contain', 'Success') }) - it.only('Can add a task to favorites', () => { + it('Can add a task to favorites', () => { TaskFactory.create(1) cy.visit('/projects/1/list') cy.get('.tasks .task .favorite') .first() .click() - cy.get('.menu.namespaces-lists') + cy.get('.menu-container') .should('contain', 'Favorites') }) diff --git a/src/components/tasks/partials/singleTaskInProject.vue b/src/components/tasks/partials/singleTaskInProject.vue index 127a4978d..2e9fa5093 100644 --- a/src/components/tasks/partials/singleTaskInProject.vue +++ b/src/components/tasks/partials/singleTaskInProject.vue @@ -260,6 +260,7 @@ function undoDone(checked: boolean) { async function toggleFavorite() { task.value.isFavorite = !task.value.isFavorite task.value = await taskService.update(task.value) + await projectStore.loadProjects() // reloading the projects list so that the Favorites project shows up or is hidden when there are (or are not) favorite tasks emit('task-updated', task.value) } diff --git a/src/stores/projects.ts b/src/stores/projects.ts index 889abf31f..ff4d19142 100644 --- a/src/stores/projects.ts +++ b/src/stores/projects.ts @@ -146,10 +146,11 @@ export const useProjectStore = defineStore('project', () => { const projectService = new ProjectService() try { - const projects = await projectService.getAll({}, {is_archived: true}) as IProject[] - setProjects(projects) + const loadedProjects = await projectService.getAll({}, {is_archived: true}) as IProject[] + projects.value = {} + setProjects(loadedProjects) - return projects + return loadedProjects } finally { cancel() }