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.
This commit is contained in:
kolaente 2026-03-19 17:31:10 +01:00
parent 2675bcb56c
commit ade91c92db
2 changed files with 0 additions and 43 deletions

View File

@ -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<IAttachment[]>([])
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))
}

View File

@ -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({