onboardingStore.js 826 B
Newer Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
Amaury Martiny's avatar
Amaury Martiny committed
// SPDX-License-Identifier: BSD-3-Clause
Amaury Martiny's avatar
Amaury Martiny committed
import { action, observable } from 'mobx';
import store from 'store';

import LS_PREFIX from './utils/lsPrefix';

const LS_KEY = `${LS_PREFIX}::firstRun`;

Amaury Martiny's avatar
Amaury Martiny committed
export class OnboardingStore {
  @observable isFirstRun; // If it's the 1st time the user is running the app

  constructor () {
    const isFirstRun = store.get(LS_KEY);

    if (isFirstRun === undefined) {
      // Set store property to true.
      this.setIsFirstRun(true);
    } else {
      this.setIsFirstRun(isFirstRun);
    }
  }

  @action
  setIsFirstRun = isFirstRun => {
    this.isFirstRun = isFirstRun;
    this.updateLS();
  };

  updateLS = () => store.set(LS_KEY, this.isFirstRun);
}

export default new OnboardingStore();