guideActions.js
1.32 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
58
59
60
61
62
63
64
65
66
/**
* # guideActions.js
*
* App user guide
*
*/
'use strict';
/**
* ## Imports
*
* The actions supported
*/
const {
GET_GUIDE_DISPLAY,
SET_GUIDE_DISPLAY
} = require('../../constants/actionTypes').default;
import {Actions} from 'react-native-router-flux';
import store from 'react-native-simple-store';
import CONFIG from '../../constants/config';
/**
* ## check guide has displayed or not
*
*/
export function getGuideDisplayState() {
return (dispatch, getState) => {
store.get(CONFIG.storeKey.GUIDE_STATE_KEY)
.then((state) => {
if (state && state.isDisplay) {
const {user} = getState();
if (user.getIn(['profile', 'sessionKey']) !== '') {
Actions.Drawer();
} else {
Actions.Login();
}
// Actions.Drawer();
} else {
Actions.Guide();
}
})
.catch(error => {
Actions.Guide();
});
}
}
/**
* ## set guide has displayed
*
*/
export function setGuideDisplayState() {
store.save(CONFIG.storeKey.GUIDE_STATE_KEY, {isDisplay: true});
Actions.Login();
return {
type: SET_GUIDE_DISPLAY,
payload: true
};
}