How to use the lockr.prefix function in lockr

To help you get started, we’ve selected a few lockr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ameobea / polotrack / frontend / src / components / AppPage.js View on Github external
constructor(props) {
    super(props);

    this.showFileUploader = this.showFileUploader.bind(this);

    // check localStorage for existing user data
    Lockr.prefix = 'userData';

    const currencyPrefs = Lockr.get('baseCurrency');
    let baseCurrency = props.baseCurrency;
    if(currencyPrefs) {
      const {currency, symbol} = JSON.parse(currencyPrefs);
      props.dispatch({type: 'globalData/baseCurrencyChanged', newBaseCurrency: currency, newBaseCurrencySymbol: symbol});
      baseCurrency = currency;
    }

    const deposits = Lockr.get('deposits');
    if(deposits) {
      props.dispatch({type: 'userData/depositHistoryUploaded', deposits: JSON.parse(deposits)});
      props.dispatch({type: 'userData/withdrawlHistoryUploaded', withdrawls: JSON.parse(Lockr.get('withdrawls'))});
      props.dispatch({type: 'userData/tradeHistoryUploaded', trades: JSON.parse(Lockr.get('trades'))});
      props.dispatch({type: 'globalData/setDemo', isDemo: JSON.parse(Lockr.get('demo'))});
      props.dispatch({type: 'userData/allDataUploaded'});
github Ameobea / polotrack / frontend / src / routes / ExampleLoader.js View on Github external
componentWillReceiveProps(nextProps) {
    const {deposits, withdrawls, trades, dispatch} = nextProps;
    if(deposits && withdrawls && trades) {
      // store the uploaded data in localStorage so it's persistant
      Lockr.prefix = 'userData';
      Lockr.set('deposits', JSON.stringify(nextProps.deposits));
      Lockr.set('withdrawls', JSON.stringify(nextProps.withdrawls));
      Lockr.set('trades', JSON.stringify(nextProps.trades));
      Lockr.set('demo', JSON.stringify(true));

      // redirect to the overview page
      dispatch({type: 'userData/allDataUploaded'});
      dispatch({type: 'globalData/setDemoFlag', isDemo: true});
      dispatch(push('/index'));

      // and then hard-refresh the page to force any components to reload from scratch
      window.location.reload();
    }
  }
github Ameobea / polotrack / frontend / src / components / FileUploader.js View on Github external
setTimeout(() => {
      this.setState({
        confirmLoading: false,
      });

      // store the uploaded data in localStorage so it's persistant
      Lockr.prefix = 'userData';
      Lockr.set('deposits', JSON.stringify(this.props.deposits));
      Lockr.set('withdrawls', JSON.stringify(this.props.withdrawls));
      Lockr.set('trades', JSON.stringify(this.props.trades));
      Lockr.set('demo', JSON.stringify(false));

      // signal that all data has been successfully uploaded and that it's time to show some juicy visualizations
      this.props.dispatch({type: 'userData/allDataUploaded'});
      this.hideFileUploader();

      // since this is real user data, set the `isDemo` flag to false
      this.props.dispatch({type: 'globalData/setDemoFlag', isDemo: false});

      // hard-refresh the page since components are wired to not watch for changes to static user data
      window.location.reload();
    }, 1234);
    this.setState({

lockr

![Lockr logo](http://i.imgur.com/m5kPjkB.png)

MIT
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis