This release scopes action state to the active reader profile. It is a breaking change for any custom component that reads from or dispatches to state.actions.keys directly.
The Redux actions.keys object was previously a flat map of action states shared across all reader types. It is now partitioned by reader profile ("epub", "webPub", "audio"), so each profile tracks its own action state independently.
// Reading state
const actionState = useAppSelector(
state => state.actions.keys[ThActionsKeys.toc]
);
// Dispatching
dispatch(setActionOpen({ key: ThActionsKeys.toc, isOpen: true }));
dispatch(toggleActionOpen({ key: ThActionsKeys.toc }));// Reading state — go through the profile first
const profile = useAppSelector(state => state.reader.profile);
const actionState = useAppSelector(
state => profile ? state.actions.keys[profile][ThActionsKeys.toc] : undefined
);
// Dispatching — include profile in every payload
if (profile) {
dispatch(setActionOpen({ key: ThActionsKeys.toc, isOpen: true, profile }));
dispatch(toggleActionOpen({ key: ThActionsKeys.toc, profile }));
}ActionsReducerState.keys is now typed as ActionKeysState:
// Before
keys: {
[key in ActionsStateKeys]?: ActionStateObject;
}
// After
interface ActionKeysState {
[profile: string]: {
[key in ActionsStateKeys]?: ActionStateObject;
};
}ActionStateOpenPayload and ActionStateTogglePayload both gained a required profile: string field.
- Replace
state.actions.keys[myKey]withstate.actions.keys[profile][myKey] - Add
const profile = useAppSelector(state => state.reader.profile)where missing - Guard dispatches with
if (profile)before callingsetActionOpen/toggleActionOpen - Add
profileto everysetActionOpen/toggleActionOpenpayload - Add
profileto theuseCallbackdependency array for anysetOpencallbacks