import store from '@/store';

// ============Guide Start===================
const GuideKey = 'MTA-Guide';

export function getGuide() {
    if (!store.state.guide) {
        let guide = JSON.parse(window.localStorage.getItem(GuideKey));
        store.commit({
                         type:   'setGuide'
                         , guide: guide,
                     });
        return guide;
    } else {
        return store.state.guide;
    }
}

export function setGuide(guide) {
    if (guide === undefined) {
        window.localStorage.removeItem(GuideKey);
        store.state.guide = null;
    } else {
        window.localStorage.setItem(GuideKey, JSON.stringify(guide));
        store.state.guide = guide;
    }
}

export function removeGuide() {
    window.localStorage.removeItem(GuideKey);
    delete store.state.guide;
}
// ============Guide End===================
