fix: avoid duplicate backlog hydration load
This commit is contained in:
parent
b489e26665
commit
38d99834ef
5 changed files with 47 additions and 8 deletions
|
|
@ -78,7 +78,10 @@ interface State {
|
|||
interface Actions {
|
||||
hydrateSnapshot(snapshot: ProductBacklogSnapshot): void
|
||||
|
||||
setActiveProduct(product: ActiveProduct | null): void
|
||||
setActiveProduct(
|
||||
product: ActiveProduct | null,
|
||||
options?: { load?: boolean; preserveSelection?: boolean },
|
||||
): void
|
||||
setActivePbi(pbiId: string | null): void
|
||||
setActiveStory(storyId: string | null): void
|
||||
setActiveTask(taskId: string | null): void
|
||||
|
|
@ -223,15 +226,18 @@ export const useProductWorkspaceStore = create<ProductWorkspaceStore>()(
|
|||
})
|
||||
},
|
||||
|
||||
setActiveProduct(product) {
|
||||
setActiveProduct(product, options) {
|
||||
const requestId = newRequestId()
|
||||
const productChanged = get().context.activeProduct?.id !== product?.id
|
||||
const shouldResetSelection = productChanged || !options?.preserveSelection
|
||||
|
||||
set((s) => {
|
||||
s.context.activeProduct = product
|
||||
s.context.activePbiId = null
|
||||
s.context.activeStoryId = null
|
||||
s.context.activeTaskId = null
|
||||
if (shouldResetSelection) {
|
||||
s.context.activePbiId = null
|
||||
s.context.activeStoryId = null
|
||||
s.context.activeTaskId = null
|
||||
}
|
||||
s.loading.activeRequestId = requestId
|
||||
|
||||
if (productChanged) {
|
||||
|
|
@ -252,7 +258,7 @@ export const useProductWorkspaceStore = create<ProductWorkspaceStore>()(
|
|||
// selectie kan herstellen. T-857: restore-flow start na ensureProductLoaded.
|
||||
writeProductHint(product?.id ?? null)
|
||||
|
||||
if (product) {
|
||||
if (product && options?.load !== false) {
|
||||
const productId = product.id
|
||||
void (async () => {
|
||||
await get().ensureProductLoaded(productId, requestId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue