From ade91c92db0febc4e468bf088e568568a0c64b03 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 19 Mar 2026 17:31:10 +0100 Subject: [PATCH] refactor(attachments): remove global attachment store The attachment store was a global singleton shared between concurrent TaskDetailView instances, causing a race condition when navigating between tasks via related tasks from the Kanban view. Attachments now live on the task ref like every other task field. --- frontend/src/stores/attachments.ts | 40 ------------------------------ frontend/src/stores/tasks.ts | 3 --- 2 files changed, 43 deletions(-) delete mode 100644 frontend/src/stores/attachments.ts diff --git a/frontend/src/stores/attachments.ts b/frontend/src/stores/attachments.ts deleted file mode 100644 index 61294d48b..000000000 --- a/frontend/src/stores/attachments.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {ref, computed, readonly} from 'vue' -import {defineStore, acceptHMRUpdate} from 'pinia' -import {findIndexById} from '@/helpers/utils' - -import type {IAttachment} from '@/modelTypes/IAttachment' - -export const useAttachmentStore = defineStore('attachment', () => { - const attachments = ref([]) - - function set(newAttachments: IAttachment[]) { - console.debug('Set attachments', newAttachments) - attachments.value = newAttachments - } - - function add(attachment: IAttachment) { - console.debug('Add attachement', attachment) - attachments.value.push(attachment) - } - - function removeById(id: IAttachment['id']) { - const attachmentIndex = findIndexById(attachments.value, id) - attachments.value.splice(attachmentIndex, 1) - console.debug('Remove attachement', id) - } - - const hasAttachments = computed(() => attachments.value.length > 0) - - return { - attachments: readonly(attachments), - set, - add, - removeById, - hasAttachments, - } -}) - -// support hot reloading -if (import.meta.hot) { - import.meta.hot.accept(acceptHMRUpdate(useAttachmentStore, import.meta.hot)) -} diff --git a/frontend/src/stores/tasks.ts b/frontend/src/stores/tasks.ts index b4c7b10b9..6926171c4 100644 --- a/frontend/src/stores/tasks.ts +++ b/frontend/src/stores/tasks.ts @@ -25,7 +25,6 @@ import type {IProject} from '@/modelTypes/IProject' import {setModuleLoading} from '@/stores/helper' import {useLabelStore} from '@/stores/labels' import {useProjectStore} from '@/stores/projects' -import {useAttachmentStore} from '@/stores/attachments' import {useKanbanStore} from '@/stores/kanban' import {useBaseStore} from '@/stores/base' import ProjectUserService from '@/services/projectUsers' @@ -108,7 +107,6 @@ async function findAssignees(parsedTaskAssignees: string[], projectId: number): export const useTaskStore = defineStore('task', () => { const baseStore = useBaseStore() const kanbanStore = useKanbanStore() - const attachmentStore = useAttachmentStore() const labelStore = useLabelStore() const projectStore = useProjectStore() const authStore = useAuthStore() @@ -205,7 +203,6 @@ export const useTaskStore = defineStore('task', () => { } kanbanStore.setTaskInBucketByIndex(newTask) } - attachmentStore.add(attachment) } async function addAssignee({