import * as types from "constants/action_types"; import lbry from "lbry"; const reducers = {}; const defaultState = { clientSettings: { showNsfw: lbry.getClientSetting("showNsfw"), themes: [], }, }; reducers[types.DAEMON_SETTINGS_RECEIVED] = function(state, action) { return Object.assign({}, state, { daemonSettings: action.data.settings, }); }; reducers[types.CLIENT_SETTING_CHANGED] = function(state, action) { const { key, value } = action.data; const clientSettings = Object.assign({}, state.clientSettings); clientSettings[key] = value; return Object.assign({}, state, { clientSettings, }); }; reducers[types.GET_THEMES] = function(state, action) { return Object.assign({}, state, { themes: action.data.themes, }); }; export default function reducer(state = defaultState, action) { const handler = reducers[action.type]; if (handler) return handler(state, action); return state; }