2019-06-22 19:24:06 +02:00
|
|
|
import { ADD, TICK } from '../constants/actionTypes'
|
2017-07-11 20:17:00 +02:00
|
|
|
|
|
|
|
export const initialState = {
|
|
|
|
lastUpdate: 0,
|
|
|
|
light: false,
|
|
|
|
count: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (state = initialState, action) => {
|
|
|
|
const { type, ts, light } = action
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case TICK: {
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
lastUpdate: ts,
|
|
|
|
light: !!light
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
case ADD: {
|
|
|
|
return Object.assign({}, state, {
|
|
|
|
count: state.count + 1
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|