forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.js
More file actions
50 lines (44 loc) · 890 Bytes
/
user.js
File metadata and controls
50 lines (44 loc) · 890 Bytes
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
import * as types from '../constants/ActionTypes';
const initialState = {
secret: null,
publicInfo: null,
updatePending: false,
users: {}
};
export default function (state = initialState, action) {
const {payload, error, meta = {}, type} = action;
const {sequence = {}} = meta;
if (sequence.type === 'start' || error) {
return state;
}
switch (type) {
case types.CHECK_TOKEN:
return {
...state,
...payload
};
case types.GET_REDUCER_FROM_ASYNC_STORAGE:
return {
...state,
...payload.user || initialState
};
case types.UPDATE_CLIENT_USER_INFO:
return {
...state,
publicInfo: payload
};
case types.GET_USER_INFO:
let {userName = "soliury"} = meta;
return {
...state,
users: {
...state.users,
[userName]: payload
}
};
case types.LOGOUT:
return initialState;
default:
return state;
}
}