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.
This commit is contained in:
kolaente
2026-02-18 22:31:09 +01:00
parent 6d6a1deba4
commit 6f8be0905f
2 changed files with 15 additions and 0 deletions

View File

@@ -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<ITask | null>(null)
const lastUpdatedTask = ref<ITask | null>(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,

View File

@@ -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<F extends Filters>(
{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<ITask>) {
const newTask = await taskService.create(new TaskModel({...task}))
tasks.value.set(newTask.id, newTask)