Fix: team members no se persistían ni cargaban al inicio
- Bug: App.vue llama fetchProjects() antes de que ProjectListView monte, el watch de projects.length nunca se disparaba - Fix: watch con immediate:true + dependencia dual (projects + users), guard teamInitialized para ejecutar una sola vez - Garantiza que loadAllTeams corra cuando AMBOS datos estén listos
This commit is contained in:
@@ -54,6 +54,7 @@ function getInitials(name: string): string {
|
|||||||
|
|
||||||
// ─── Per-project team members ───────────────
|
// ─── Per-project team members ───────────────
|
||||||
const teamByProject = ref<Map<number, number[]>>(new Map())
|
const teamByProject = ref<Map<number, number[]>>(new Map())
|
||||||
|
const teamInitialized = ref(false)
|
||||||
const teamDialogProjectId = ref<number | null>(null)
|
const teamDialogProjectId = ref<number | null>(null)
|
||||||
const teamDialogOpen = ref(false)
|
const teamDialogOpen = ref(false)
|
||||||
const pendingTeam = ref<Set<number>>(new Set())
|
const pendingTeam = ref<Set<number>>(new Set())
|
||||||
@@ -96,9 +97,16 @@ async function loadAllTeams() {
|
|||||||
teamByProject.value = map
|
teamByProject.value = map
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => projects.projects.length, async () => {
|
watch(
|
||||||
if (projects.projects.length > 0) await loadAllTeams()
|
[() => projects.projects.length, () => usersStore.users.length],
|
||||||
})
|
async ([pLen, uLen]) => {
|
||||||
|
if (pLen > 0 && uLen > 0 && !teamInitialized.value) {
|
||||||
|
teamInitialized.value = true
|
||||||
|
await loadAllTeams()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
function getTeamMembers(projectId: number): AlphaUser[] {
|
function getTeamMembers(projectId: number): AlphaUser[] {
|
||||||
const ids = teamByProject.value.get(projectId) ?? []
|
const ids = teamByProject.value.get(projectId) ?? []
|
||||||
|
|||||||
Reference in New Issue
Block a user