reducers simplification
This commit is contained in:
parent
f9c519ca83
commit
27253aeba1
4
client/assets/styles/skeleton.css
vendored
4
client/assets/styles/skeleton.css
vendored
@ -157,11 +157,11 @@ p {
|
||||
|
||||
/* Links
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
a {
|
||||
/*a {
|
||||
color: #1EAEDB; }
|
||||
a:hover {
|
||||
color: #0FA0CE; }
|
||||
|
||||
*/
|
||||
|
||||
/* Buttons
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– */
|
||||
|
||||
@ -1,225 +1,36 @@
|
||||
const actions = require('./actions');
|
||||
|
||||
const defaultAccount = null;
|
||||
function accountReducer(state = defaultAccount, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_ACCOUNT:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultPing = null;
|
||||
function pingReducer(state = defaultPing, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_PING:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultVboxInfo = { combos: [], vars: [] };
|
||||
function vboxInfoReducer(state = defaultVboxInfo, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_VBOX_INFO:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultVboxHighlight = [];
|
||||
function vboxHighlightReducer(state = defaultVboxHighlight, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_VBOX_HIGHLIGHT:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultActiveSkill = null;
|
||||
function activeSkillReducer(state = defaultActiveSkill, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_ACTIVE_SKILL:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultActiveVar = null;
|
||||
function activeVarReducer(state = defaultActiveVar, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_ACTIVE_VAR:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultActiveCryp = null;
|
||||
function activeCrypReducer(state = defaultActiveCryp, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_ACTIVE_CRYP:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultCryps = null;
|
||||
function crypsReducer(state = defaultCryps, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_CRYPS:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultInstances = [];
|
||||
function instancesReducer(state = defaultInstances, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_INSTANCES:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultInstance = null;
|
||||
function instanceReducer(state = defaultInstance, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_INSTANCE:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultPlayer = null;
|
||||
function playerReducer(state = defaultPlayer, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_PLAYER:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultSelectedCryps = [null, null, null];
|
||||
function selectedCrypsReducer(state = defaultSelectedCryps, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_SELECTED_CRYPS:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultCombiner = [null, null, null];
|
||||
function combinerReducer(state = defaultCombiner, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_COMBINER:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultGame = null;
|
||||
function gameReducer(state = defaultGame, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_GAME:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultResolution = null;
|
||||
function resolutionReducer(state = defaultResolution, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_RESOLUTION:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultShowLog = false;
|
||||
function showLogReducer(state = defaultShowLog, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_SHOW_LOG:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultVboxHidden = false;
|
||||
function vboxHiddenReducer(state = defaultVboxHidden, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_VBOX_HIDDEN:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultReclaiming = false;
|
||||
function reclaimingReducer(state = defaultReclaiming, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_RECLAIMING:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultWs = null;
|
||||
function wsReducer(state = defaultWs, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_WS:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultInfo = [null, null];
|
||||
function infoReducer(state = defaultInfo, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_INFO:
|
||||
if (!action.value) debugger
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
function createReducer(defaultState, actionType) {
|
||||
return function reducer(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
case actionType:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* eslint-disable key-spacing */
|
||||
module.exports = {
|
||||
accountReducer,
|
||||
activeSkillReducer,
|
||||
activeCrypReducer,
|
||||
activeVarReducer,
|
||||
combinerReducer,
|
||||
crypsReducer,
|
||||
gameReducer,
|
||||
showLogReducer,
|
||||
vboxHiddenReducer,
|
||||
instanceReducer,
|
||||
instancesReducer,
|
||||
playerReducer,
|
||||
reclaimingReducer,
|
||||
selectedCrypsReducer,
|
||||
resolutionReducer,
|
||||
wsReducer,
|
||||
infoReducer,
|
||||
pingReducer,
|
||||
vboxInfoReducer,
|
||||
vboxHighlightReducer,
|
||||
accountReducer: createReducer(null, actions.SET_ACCOUNT),
|
||||
activeCrypReducer: createReducer(null, actions.SET_ACTIVE_CRYP),
|
||||
activeSkillReducer: createReducer(null, actions.SET_ACTIVE_SKILL),
|
||||
activeVarReducer: createReducer(null, actions.SET_ACTIVE_VAR),
|
||||
combinerReducer: createReducer([null, null, null], actions.SET_COMBINER),
|
||||
crypsReducer: createReducer([], actions.SET_CRYPS),
|
||||
gameReducer: createReducer(null, actions.SET_GAME),
|
||||
infoReducer: createReducer([null, null], actions.SET_INFO),
|
||||
instanceReducer: createReducer(null, actions.SET_INSTANCE),
|
||||
instancesReducer: createReducer([], actions.SET_INSTANCES),
|
||||
pingReducer: createReducer(null, actions.SET_PING),
|
||||
playerReducer: createReducer(null, actions.SET_PLAYER),
|
||||
reclaimingReducer: createReducer(false, actions.SET_RECLAIMING),
|
||||
resolutionReducer: createReducer(null, actions.SET_RESOLUTION),
|
||||
selectedCrypsReducer: createReducer([null, null, null], actions.SET_SELECTED_CRYPS),
|
||||
showLogReducer: createReducer(false, actions.SET_SHOW_LOG),
|
||||
vboxHiddenReducer: createReducer(false, actions.SET_VBOX_HIDDEN),
|
||||
vboxHighlightReducer: createReducer([], actions.SET_VBOX_HIGHLIGHT),
|
||||
vboxInfoReducer: createReducer({ combos: [], vars: [] }, actions.SET_VBOX_INFO),
|
||||
wsReducer: createReducer(null, actions.SET_WS),
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user