From 6f8be0905fec67738e3869108fa2467520497c29 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 18 Feb 2026 22:31:09 +0100 Subject: [PATCH] fix(gantt): sync task updates from detail view back to gantt chart The Gantt chart maintains its own local task map, separate from the Pinia task store. When a task is edited in the detail modal, the update was not propagated to the Gantt's map. Add a lastUpdatedTask signal to the task store and watch it in useGanttTaskList. --- frontend/src/stores/tasks.ts | 3 +++ .../src/views/project/helpers/useGanttTaskList.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/frontend/src/stores/tasks.ts b/frontend/src/stores/tasks.ts index 3ceb7a25f..030fc7370 100644 --- a/frontend/src/stores/tasks.ts +++ b/frontend/src/stores/tasks.ts @@ -114,6 +114,7 @@ export const useTaskStore = defineStore('task', () => { const tasks = ref<{ [id: ITask['id']]: ITask }>({}) // TODO: or is this ITask[] const isLoading = ref(false) const draggedTask = ref(null) + const lastUpdatedTask = ref(null) const hasTasks = computed(() => Object.keys(tasks.value).length > 0) @@ -163,6 +164,7 @@ export const useTaskStore = defineStore('task', () => { try { const updatedTask = await taskService.update(task) kanbanStore.ensureTaskIsInCorrectBucket(updatedTask) + lastUpdatedTask.value = updatedTask return updatedTask } finally { cancel() @@ -541,6 +543,7 @@ export const useTaskStore = defineStore('task', () => { tasks, isLoading, draggedTask, + lastUpdatedTask, hasTasks, diff --git a/frontend/src/views/project/helpers/useGanttTaskList.ts b/frontend/src/views/project/helpers/useGanttTaskList.ts index 3fe2bf3c2..9d28add3f 100644 --- a/frontend/src/views/project/helpers/useGanttTaskList.ts +++ b/frontend/src/views/project/helpers/useGanttTaskList.ts @@ -10,6 +10,7 @@ import TaskService from '@/services/task' import TaskModel from '@/models/task' import {error, success} from '@/message' import {useAuthStore} from '@/stores/auth' +import {useTaskStore} from '@/stores/tasks' import type {IProjectView} from '@/modelTypes/IProjectView' export interface UseGanttTaskListReturn { @@ -70,6 +71,17 @@ export function useGanttTaskList( {immediate: true, deep: true}, ) + // Sync task updates from other views (e.g. task detail modal) + const taskStore = useTaskStore() + watch( + () => taskStore.lastUpdatedTask, + (updatedTask) => { + if (updatedTask && tasks.value.has(updatedTask.id)) { + tasks.value.set(updatedTask.id, updatedTask) + } + }, + ) + async function addTask(task: Partial) { const newTask = await taskService.create(new TaskModel({...task})) tasks.value.set(newTask.id, newTask)