Newer
Older
CrypticOreWallet / src / store / reducers / SettingsReducer.ts
@Drew Lemmy Drew Lemmy on 19 Feb 2021 546 bytes feat: sync balances with websocket
import { createReducer, ActionType } from "typesafe-actions";
import { loadSettings, SettingsState } from "../../utils/settings";
import { setBooleanSetting } from "../actions/SettingsActions";

export type State = SettingsState;

export function getInitialSettingsState(): State {
  return loadSettings();
}

export const SettingsReducer = createReducer({} as State)
  .handleAction(setBooleanSetting, (state: State, action: ActionType<typeof setBooleanSetting>) => ({
    ...state,
    [action.payload.settingName]: action.payload.value
  }));