guideActions.js 1.04 KB
/**
 * # 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';

const guideDisplayState = 'guideDisplayState';

/**
 * ## check guide has displayed or not 
 *
 */
export function getDisplayState() {

    return dispatch => {
        store.get(guideDisplayState)
            .then((state) => {
                if (state) {
                    Actions.Drawer();
                } else {
                    Actions.Guide();
                }
            })
            .catch(error => {
                console.error(error);
                Actions.Drawer();
            });
    }
}
/**
 * ## set guide has displayed
 *
 */
export function setDisplayState() {
    
    store.save(guideDisplayState, true);

    Actions.Drawer();
    return {
        type: SET_GUIDE_DISPLAY,
        payload: true
    };


}