Workspace-store is nu de enige bron voor product-backlog client-state. De
vier voorgangers en de dual-dispatch-infrastructuur zijn verwijderd.
- T-872: grep over codebase op useBacklogStore/usePlannerStore/
useSelectionStore/useProductStore is leeg.
- T-873..T-876: stores/{backlog,planner,selection,product}-store.ts deleted.
- T-877: __tests__/realtime/payload-contract.test.ts en
__tests__/api/backlog-realtime.test.ts deleted — pbi/story/task I|U|D
payload-handling wordt al gedekt door
__tests__/stores/product-workspace/store.test.ts (incl. parent-move,
idempotent inserts, delete-cleanup).
- T-878: lib/realtime/dev-workspace-fingerprint.ts deleted, dual-dispatch
uit BacklogHydrationWrapper en lib/realtime/use-backlog-realtime.ts
weggehaald. stores/products-store.ts (lijst van producten ≠ active
product) blijft ongewijzigd.
Bijwerkingen:
- BacklogPbi en BacklogStory types in components/backlog/story-panel.tsx en
components/sprint/sprint-backlog.tsx krijgen sort_order zodat ze met de
workspace-types overeenkomen.
- Server-pages /products/[id]/page.tsx (desktop+mobile) en
/products/[id]/sprint/[sprintId]/page.tsx selecteren sort_order op story
en mappen het door in de hydration-payload.
Verify: lint+typecheck clean, 626/626 tests groen (verlies van 25 redundante
oude-store tests; workspace-store tests dekken hetzelfde gedrag).
Refs: PBI-74, ST-1325, T-872..T-878
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect, useRef } from 'react'
|
|
import { useBacklogRealtime } from '@/lib/realtime/use-backlog-realtime'
|
|
import { useWorkspaceResync } from '@/lib/realtime/use-workspace-resync'
|
|
import { useProductWorkspaceStore } from '@/stores/product-workspace/store'
|
|
import type {
|
|
BacklogPbi,
|
|
BacklogStory,
|
|
BacklogTask,
|
|
ProductBacklogSnapshot,
|
|
} from '@/stores/product-workspace/types'
|
|
|
|
interface InitialData {
|
|
pbis: BacklogPbi[]
|
|
storiesByPbi: Record<string, BacklogStory[]>
|
|
tasksByStory: Record<string, BacklogTask[]>
|
|
}
|
|
|
|
interface BacklogHydrationWrapperProps {
|
|
initialData: InitialData
|
|
productId: string
|
|
productName?: string
|
|
children: React.ReactNode
|
|
}
|
|
|
|
function fingerprint(data: InitialData): string {
|
|
const pbiPart = data.pbis.map((p) => `${p.id}:${p.status}:${p.priority}`).join(',')
|
|
const storyPart = Object.entries(data.storiesByPbi)
|
|
.flatMap(([, list]) => list.map((s) => `${s.id}:${s.status}:${s.sprint_id ?? 'null'}`))
|
|
.join(',')
|
|
const taskPart = Object.entries(data.tasksByStory)
|
|
.flatMap(([, list]) => list.map((t) => `${t.id}:${t.status}`))
|
|
.join(',')
|
|
return `${pbiPart}|${storyPart}|${taskPart}`
|
|
}
|
|
|
|
// PBI-74 / Story 8: workspace-store is nu enige bron — dual-dispatch weg.
|
|
function toWorkspaceSnapshot(
|
|
data: InitialData,
|
|
productId: string,
|
|
productName: string | undefined,
|
|
): ProductBacklogSnapshot {
|
|
return {
|
|
product: { id: productId, name: productName ?? '' },
|
|
pbis: data.pbis,
|
|
storiesByPbi: data.storiesByPbi,
|
|
tasksByStory: data.tasksByStory,
|
|
}
|
|
}
|
|
|
|
export function BacklogHydrationWrapper({
|
|
initialData,
|
|
productId,
|
|
productName,
|
|
children,
|
|
}: BacklogHydrationWrapperProps) {
|
|
const lastFingerprint = useRef<string>('')
|
|
|
|
useEffect(() => {
|
|
const fp = fingerprint(initialData)
|
|
if (fp !== lastFingerprint.current) {
|
|
lastFingerprint.current = fp
|
|
useProductWorkspaceStore
|
|
.getState()
|
|
.hydrateSnapshot(toWorkspaceSnapshot(initialData, productId, productName))
|
|
}
|
|
}, [initialData, productId, productName])
|
|
|
|
useBacklogRealtime(productId)
|
|
useWorkspaceResync()
|
|
|
|
return <>{children}</>
|
|
}
|