1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00
Files
Boostnote/browser/main/HomeContainer/reducer.js
2015-10-12 22:29:24 +09:00

33 lines
737 B
JavaScript

import { combineReducers } from 'redux'
import { PARAMS_CHANGE, USER_UPDATE } from './actions'
const initialCurrentUser = JSON.parse(localStorage.getItem('currentUser'))
const initialParams = {}
function currentUser (state, action) {
switch (action.type) {
case USER_UPDATE:
let user = action.data
localStorage.setItem('currentUser', JSON.stringify(user))
return user
default:
if (state == null) return initialCurrentUser
return state
}
}
function params (state, action) {
switch (action.type) {
case PARAMS_CHANGE:
return action.data
default:
if (state == null) return initialParams
return state
}
}
export default combineReducers({
currentUser,
params
})