File tree Expand file tree Collapse file tree
src/hooks/useOpeningDrillController Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -300,7 +300,24 @@ export const useOpeningDrillController = (
300300
301301 const performanceData = evaluateDrillPerformance ( drillGame )
302302 setCurrentPerformanceData ( performanceData )
303- setCompletedDrills ( ( prev ) => [ ...prev , performanceData . drill ] )
303+
304+ // Check if this drill already exists in completedDrills and update it instead of adding new
305+ setCompletedDrills ( ( prev ) => {
306+ const existingIndex = prev . findIndex (
307+ ( completedDrill ) =>
308+ completedDrill . selection . id === drillGame . selection . id ,
309+ )
310+
311+ if ( existingIndex !== - 1 ) {
312+ // Update existing drill
313+ const updated = [ ...prev ]
314+ updated [ existingIndex ] = performanceData . drill
315+ return updated
316+ } else {
317+ // Add new drill
318+ return [ ...prev , performanceData . drill ]
319+ }
320+ } )
304321
305322 // Don't remove from remaining drills here - do it in moveToNextDrill
306323 // This ensures proper counting for the performance modal
You can’t perform that action at this time.
0 commit comments