deviceReducer.js
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* # deviceReducer.js
*
* The reducer for all the actions from the various log states
*/
'use strict';
/**
* ## Imports
*
* InitialState
*/
import InitialState from './deviceInitialState';
/**
* Device actions to test
*/
const {
SET_PLATFORM,
SET_VERSION,
SHOW_DOT
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
/**
* ## deviceReducer function
* @param {Object} state - initialState
* @param {Object} action - type and payload
*/
export default function deviceReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
/**
* ### set the platform in the state
*
*/
case SET_PLATFORM:
const platform = action.payload;
return state.set('platform', platform);
/**
* ### set the version in the state
*
*/
case SET_VERSION:
const version = action.payload;
return state.set('version', version);
case SHOW_DOT:
const dot = action.payload;
return state.set('dot', dot);
}
return state;
}