Merge pull request #30 from Gimanh/fix/lists-load-for-taskdetail

fix: lists load for task details
This commit is contained in:
Gimanh
2026-03-08 18:11:59 +01:00
committed by GitHub
2 changed files with 14 additions and 4 deletions
@@ -68,6 +68,7 @@ import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useGoalListsStore } from '@/stores/goal-lists.store'
import { useTasksStore } from '@/stores/tasks.store'
import { useProjectContext } from '@/composables/useProjectContext'
import { ALL_TASKS_LIST_ID } from 'taskview-api'
import { useColor } from '@/composables/useColotMode'
@@ -79,8 +80,9 @@ const props = defineProps<{
const { t } = useI18n()
const goalListsStore = useGoalListsStore()
const tasksStore = useTasksStore()
const projectContext = useProjectContext()
const { isDark } = useColor()
const lists = computed(() => goalListsStore.lists)
const lists = computed(() => projectContext?.lists.value ?? goalListsStore.lists)
const listItems = computed(() => [
{ label: t('tasks.noList'), value: ALL_TASKS_LIST_ID },
+11 -3
View File
@@ -1,10 +1,11 @@
import { ref, computed, watch, provide, inject, type InjectionKey, type Ref, type ComputedRef } from 'vue'
import type { CollaborationResponseFetchAllUsers, KanbanColumnItem } from 'taskview-api'
import type { CollaborationResponseFetchAllUsers, GoalListItem, KanbanColumnItem } from 'taskview-api'
import type { TagItem } from '@/types/tags.types'
import { DEFAULT_ID } from '@/types/app.types'
import { $tvApi } from '@/plugins/axios'
import { useTagsStore } from '@/stores/tag.store'
import { useGoalsStore } from '@/stores/goals.store'
import { useGoalListsStore } from '@/stores/goal-lists.store'
import { useCollaborationStore } from '@/stores/collaboration.store'
import { useKanbanStore } from '@/stores/kanban.store'
@@ -12,6 +13,7 @@ export type ProjectContext = {
tags: ComputedRef<TagItem[]>
users: Ref<CollaborationResponseFetchAllUsers[]>
statuses: Ref<KanbanColumnItem[]>
lists: Ref<GoalListItem[]>
}
const PROJECT_CONTEXT_KEY: InjectionKey<ProjectContext> = Symbol('projectContext')
@@ -30,12 +32,14 @@ export function provideProjectContext(goalId: Ref<number>) {
const users = ref<CollaborationResponseFetchAllUsers[]>([])
const statuses = ref<KanbanColumnItem[]>([])
const lists = ref<GoalListItem[]>([])
let requestId = 0
watch(goalId, async (id) => {
if (id <= 0) {
users.value = []
statuses.value = []
lists.value = []
return
}
@@ -47,17 +51,20 @@ export function provideProjectContext(goalId: Ref<number>) {
if (goalsStore.selectedItemId === id) {
const collaborationStore = useCollaborationStore()
const kanbanStore = useKanbanStore()
const goalListsStore = useGoalListsStore()
users.value = collaborationStore.users
statuses.value = kanbanStore.statuses
lists.value = goalListsStore.lists
return
}
// Otherwise fetch project data without touching global stores
const currentRequestId = ++requestId
const [usersResult, columnsResult] = await Promise.all([
const [usersResult, columnsResult, listsResult] = await Promise.all([
$tvApi.collaboration.fetchUsersForGoal(id).catch(() => null),
$tvApi.kanban.fetchAllColumns(id).catch(() => null),
$tvApi.goalLists.fetchLists({ goalId: id }).catch(() => null),
])
// Stale check — goalId could have changed while requests were in flight
@@ -70,9 +77,10 @@ export function provideProjectContext(goalId: Ref<number>) {
...columnsResult,
]
}
if (listsResult) lists.value = listsResult
}, { immediate: true })
const context: ProjectContext = { tags, users, statuses }
const context: ProjectContext = { tags, users, statuses, lists }
provide(PROJECT_CONTEXT_KEY, context)
return context