fix: discipline-slice.ts directly mutates state outside of set() #26
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: Critical
File:
src/lib/game/stores/discipline-slice.ts(line 94)Problem: In
processTick, the linedisc.paused = true;mutates the discipline state object directly on the current state, bypassing Zustand's state management. This happens insideget()but outside ofset().Impact: Zustand won't detect the change, won't trigger re-renders, and the mutation may be lost or cause inconsistent state. The
pausedflag may not persist correctly.Fix: Build a new
disciplinesmap with the paused discipline replaced immutably, then include it in theset()call at the end ofprocessTick:Starting work on discipline-slice.ts directly mutates state outside set()
Fixed: Replaced direct mutation
disc.paused = truewith immutablenewDisciplines[id] = { ...disc, paused: true }in discipline-slice.ts processTick