Init history in dapp module

This commit is contained in:
Jaco Greeff
2017-08-30 11:29:15 +02:00
parent b1428c2b56
commit d7de40ab4c
2 changed files with 22 additions and 24 deletions

View File

@@ -19,10 +19,24 @@ import { observer } from 'mobx-react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import Api from '@parity/api';
import builtinDapps from '@parity/shared/config/dappsBuiltin.json';
import viewsDapps from '@parity/shared/config/dappsViews.json';
import DappsStore from '@parity/shared/mobx/dappsStore';
import HistoryStore from '@parity/shared/mobx/historyStore';
import styles from './dapp.css';
const internalDapps = []
.concat(viewsDapps, builtinDapps)
.map((app) => {
if (app.id && app.id.substr(0, 2) !== '0x') {
app.id = Api.util.sha3(app.id);
}
return app;
});
@observer
export default class Dapp extends Component {
static contextTypes = {
@@ -39,10 +53,15 @@ export default class Dapp extends Component {
};
store = DappsStore.get(this.context.api);
historyStore = HistoryStore.get('dapps');
componentWillMount () {
const { id } = this.props.params;
if (!internalDapps[id] || !internalDapps[id].skipHistory) {
this.historyStore.add(id);
}
this.loadApp(id);
}