fix(ideation): update progress calculation to include just-completed ideation type (#381)
Adjusted the progress calculation in the ideation store to account for the newly completed ideation type. This change ensures that the state updates are accurately reflected, especially with React 18's batching behavior. The updated logic now includes the completed type in the calculation of completed counts, improving the accuracy of progress tracking. Co-authored-by: Andy <119136210+AndyMik90@users.noreply.github.com>
This commit is contained in:
@@ -650,9 +650,16 @@ export function setupIdeationListeners(): () => void {
|
||||
store().addLog(`✓ ${ideationType} completed with ${ideas.length} ideas`);
|
||||
|
||||
// Update progress based on completed types
|
||||
const typeStates = store().typeStates;
|
||||
// Calculate with the expected state since React 18 batches state updates.
|
||||
// The Zustand update from addIdeasForType() is batched and won't be visible
|
||||
// until after this event handler completes, so we manually include the
|
||||
// just-completed type in the calculation.
|
||||
const config = store().config;
|
||||
const completedCount = Object.entries(typeStates).filter(
|
||||
const typeStates = store().typeStates;
|
||||
|
||||
// Mark as completed in the calculation
|
||||
const updatedStates = { ...typeStates, [ideationType]: 'completed' };
|
||||
const completedCount = Object.entries(updatedStates).filter(
|
||||
([type, state]) =>
|
||||
config.enabledTypes.includes(type as IdeationType) &&
|
||||
(state === 'completed' || state === 'failed')
|
||||
|
||||
Reference in New Issue
Block a user