Refactor useEncounter from useState to useReducer
Replaces 18 useCallback wrappers with a typed action union and encounterReducer. Undo/redo wrapping is now systematic per-case in the reducer instead of ad-hoc per operation. Complex cases (undo/redo, bestiary add, player character add) are extracted into helper functions. The stat block auto-show on bestiary add now uses lastCreatureId from reducer state instead of the synchronous return value, with a useEffect in use-action-bar-state to react to changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,7 @@ function mockContext(overrides: Partial<Encounter> = {}) {
|
||||
setEncounter: vi.fn(),
|
||||
setUndoRedoState: vi.fn(),
|
||||
events: [],
|
||||
lastCreatureId: null,
|
||||
};
|
||||
|
||||
mockUseEncounterContext.mockReturnValue(
|
||||
|
||||
Reference in New Issue
Block a user