From 7155cd54520df006a511c1e991c9dc0cdcaa9597 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 7 Jun 2018 11:34:09 +0200 Subject: [PATCH 1/4] Add a AccountsList component --- src/Accounts/Accounts.js | 91 ++------------------- src/Accounts/AccountsList/AccountsList.js | 99 +++++++++++++++++++++++ src/Accounts/AccountsList/index.js | 8 ++ 3 files changed, 112 insertions(+), 86 deletions(-) create mode 100644 src/Accounts/AccountsList/AccountsList.js create mode 100644 src/Accounts/AccountsList/index.js diff --git a/src/Accounts/Accounts.js b/src/Accounts/Accounts.js index 6decf0d6..b48d4cad 100644 --- a/src/Accounts/Accounts.js +++ b/src/Accounts/Accounts.js @@ -3,103 +3,22 @@ // // SPDX-License-Identifier: MIT -import React, { Component } from 'react'; -import { accountsInfo$ } from '@parity/light.js'; -import Blockies from 'react-blockies'; -import { inject, observer } from 'mobx-react'; +import React, { PureComponent } from 'react'; import { Redirect, Route, Switch } from 'react-router-dom'; -import Health from '../Health'; -import CreateAccount from './CreateAccount/CreateAccount'; -import light from '../hoc'; - -@light({ - accountsInfo: accountsInfo$ -}) -@inject('createAccountStore', 'parityStore') -@observer -class Accounts extends Component { - handleClick = ({ currentTarget: { dataset: { address } } }) => { - const { history, parityStore: { api } } = this.props; - // Set default account to the clicked one, and go to Tokens on complete - this.subscription = api.parity - .setNewDappsDefaultAddress(address) - .then(() => history.push('/tokens')); - }; - - handleCreateAccount = () => { - this.props.createAccountStore.setIsImporting(false); - this.props.history.push('/accounts/new'); - }; +import AccountsList from './AccountsList'; +import CreateAccount from './CreateAccount'; +class Accounts extends PureComponent { render () { return ( - + ); } - - // TODO We can put this into a separate Component - renderAccounts = () => { - const { accountsInfo } = this.props; - - return ( -
- - -
-
- {accountsInfo - ?
    - {Object.keys(accountsInfo).map(address => -
  • -
    -
    - -
    -
    -
    - {accountsInfo[address].name} -
    -
    - {address} -
    -
    -
    -
  • - )} -
- :
-

Loading…

-
} -
-
- - -
- ); - }; } export default Accounts; diff --git a/src/Accounts/AccountsList/AccountsList.js b/src/Accounts/AccountsList/AccountsList.js new file mode 100644 index 00000000..a0e1eb01 --- /dev/null +++ b/src/Accounts/AccountsList/AccountsList.js @@ -0,0 +1,99 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +import React, { Component } from 'react'; +import { accountsInfo$ } from '@parity/light.js'; +import Blockies from 'react-blockies'; +import { inject, observer } from 'mobx-react'; + +import Health from '../../Health'; +import light from '../../hoc'; + +@light({ + accountsInfo: accountsInfo$ +}) +@inject('createAccountStore', 'parityStore') +@observer +class AccountsList extends Component { + handleClick = ({ + currentTarget: { + dataset: { address } + } + }) => { + const { + history, + parityStore: { api } + } = this.props; + // Set default account to the clicked one, and go to Tokens on complete + this.subscription = api.parity + .setNewDappsDefaultAddress(address) + .then(() => history.push('/tokens')); + }; + + handleCreateAccount = () => { + this.props.createAccountStore.setIsImporting(false); + this.props.history.push('/accounts/new'); + }; + + render () { + const { accountsInfo } = this.props; + + return ( +
+ + +
+
+ {accountsInfo ? ( +
    + {Object.keys(accountsInfo).map(address => ( +
  • +
    +
    + +
    +
    +
    + {accountsInfo[address].name} +
    +
    {address}
    +
    +
    +
  • + ))} +
+ ) : ( +
+

Loading…

+
+ )} +
+
+ + +
+ ); + } +} + +export default AccountsList; diff --git a/src/Accounts/AccountsList/index.js b/src/Accounts/AccountsList/index.js new file mode 100644 index 00000000..0cc92571 --- /dev/null +++ b/src/Accounts/AccountsList/index.js @@ -0,0 +1,8 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +import AccountsList from './AccountsList'; + +export default AccountsList; -- GitLab From 9d4b35a12c17349b7902f80729265b3312dab2d6 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 7 Jun 2018 13:36:10 +0200 Subject: [PATCH 2/4] Add onboarding process --- .../AccountConfirm/AccountConfirm.js | 15 +++- src/Accounts/CreateAccount/CreateAccount.js | 51 +++++++----- src/App/App.js | 82 +++++++++++++------ src/Onboarding/Onboarding.js | 42 ++++++++++ src/Onboarding/index.js | 8 ++ src/stores/firstRunStore.js | 34 ++++++++ src/stores/index.js | 2 + src/stores/parityStore.js | 5 +- src/stores/tokensStore.js | 17 ++-- src/stores/utils/lsPrefix.js | 7 ++ 10 files changed, 205 insertions(+), 58 deletions(-) create mode 100644 src/Onboarding/Onboarding.js create mode 100644 src/Onboarding/index.js create mode 100644 src/stores/firstRunStore.js create mode 100644 src/stores/utils/lsPrefix.js diff --git a/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js b/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js index 61981dbe..a5fbaf20 100644 --- a/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js +++ b/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js @@ -8,11 +8,22 @@ import { inject, observer } from 'mobx-react'; import CreateAccountHeader from '../CreateAccountHeader'; -@inject('createAccountStore') +@inject('createAccountStore', 'firstRunStore') @observer class AccountConfirm extends Component { handleSubmit = () => { - const { createAccountStore: { saveAccountToParity }, history } = this.props; + const { + createAccountStore: { saveAccountToParity }, + history, + firstRunStore + } = this.props; + + // If we were onboarding, set isFirstRun to false, so that we quit + // onboarding. + if (firstRunStore.isFirstRun) { + firstRunStore.setIsFirstRun(false); + } + saveAccountToParity().then(() => history.push('/accounts')); }; diff --git a/src/Accounts/CreateAccount/CreateAccount.js b/src/Accounts/CreateAccount/CreateAccount.js index 88e4d835..2bc9fd81 100644 --- a/src/Accounts/CreateAccount/CreateAccount.js +++ b/src/Accounts/CreateAccount/CreateAccount.js @@ -4,7 +4,7 @@ // SPDX-License-Identifier: MIT import React, { Component } from 'react'; -import { Link, Route } from 'react-router-dom'; +import { Route } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; import memoize from 'lodash/memoize'; @@ -33,20 +33,24 @@ class CreateAccount extends Component { ]; }); - handleImportAccount = () => { - this.props.createAccountStore.setIsImporting(true); + handleCreateAccount = () => { + this.props.createAccountStore.setIsImporting(false); this.props.history.push('/accounts/new'); }; - handleCreateAccount = () => { - this.props.createAccountStore.setIsImporting(false); + handleGoBack = () => this.props.history.goBack(); + + handleImportAccount = () => { + this.props.createAccountStore.setIsImporting(true); this.props.history.push('/accounts/new'); }; render () { const { createAccountStore: { isImport }, - match: { params: { step } } // Current step + match: { + params: { step } + } // Current step } = this.props; // Get all the steps of our account process @@ -56,18 +60,16 @@ class CreateAccount extends Component {
- {Steps.map((StepComponent, index) => + {Steps.map((StepComponent, index) => ( - )} + ))}
diff --git a/src/App/App.js b/src/App/App.js index 87f81feb..dd3b9372 100644 --- a/src/App/App.js +++ b/src/App/App.js @@ -4,6 +4,7 @@ // SPDX-License-Identifier: MIT import React, { Component } from 'react'; +import { accounts$ } from '@parity/light.js'; import { BrowserRouter, MemoryRouter, @@ -14,6 +15,8 @@ import { import { inject, observer } from 'mobx-react'; import Accounts from '../Accounts'; +import light from '../hoc'; +import Onboarding from '../Onboarding'; import Overlay from '../Overlay'; import Receive from '../Receive'; import Send from '../Send'; @@ -28,16 +31,13 @@ import './App.css'; const Router = process.env.NODE_ENV === 'production' ? MemoryRouter : BrowserRouter; -@inject('healthStore') +@light({ + accounts: accounts$ +}) +@inject('healthStore', 'firstRunStore') @observer class App extends Component { render () { - const { - healthStore: { - health: { status } - } - } = this.props; - return (
@@ -47,28 +47,62 @@ class App extends Component {
-
- {status === STATUS.GOOD ? ( - - {/* Change homepage on the next line */} - - - - - - - - - - ) : ( - - )} -
+
{this.renderScreen()}
); } + + /** + * Decide which screen to render. + */ + renderScreen () { + const { + accounts, + firstRunStore, + healthStore: { + health: { status } + } + } = this.props; + const { isFirstRun } = firstRunStore; + + // We show the onboarding process if: + // - either it's the 1st time the user runs this app + // - or the user has 0 account + const isOnboarding = + // If either of the two is undefined, then it means we're still fetching. + // This doesn't count as onboarding. + accounts === undefined || isFirstRun === undefined + ? false + : isFirstRun || !accounts.length; + + // If we are onboarding, then never show the Overlay. On the other hand, if + // we're not onboarding, show the Overlay whenever we have an issue. + if (!isOnboarding && status !== STATUS.GOOD) { + return ; + } + + return ( + + {/* We redirect to Onboarding if necessary, or by default to our + homepage which is Tokens */} + + + + + + + + + + + ); + } } export default App; diff --git a/src/Onboarding/Onboarding.js b/src/Onboarding/Onboarding.js new file mode 100644 index 00000000..1c4dc2a5 --- /dev/null +++ b/src/Onboarding/Onboarding.js @@ -0,0 +1,42 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +import React, { PureComponent } from 'react'; +import { accounts$ } from '@parity/light.js'; +import { inject } from 'mobx-react'; +import { Link } from 'react-router-dom'; + +import Health from '../Health'; +import light from '../hoc'; + +@light({ + accounts: accounts$ +}) +@inject('firstRunStore') +class Onboarding extends PureComponent { + handleFirstRun = () => { + // Not first run anymore after clicking Start + this.props.firstRunStore.setIsFirstRun(false); + }; + + render () { + const { accounts } = this.props; + return ( +
+ This is the onboarding page.
+ {accounts && accounts.length ? ( + + Start + + ) : ( + Create account + )} + +
+ ); + } +} + +export default Onboarding; diff --git a/src/Onboarding/index.js b/src/Onboarding/index.js new file mode 100644 index 00000000..ac178853 --- /dev/null +++ b/src/Onboarding/index.js @@ -0,0 +1,8 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +import Onboarding from './Onboarding'; + +export default Onboarding; diff --git a/src/stores/firstRunStore.js b/src/stores/firstRunStore.js new file mode 100644 index 00000000..19cfe074 --- /dev/null +++ b/src/stores/firstRunStore.js @@ -0,0 +1,34 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +import { action, observable } from 'mobx'; +import store from 'store'; + +import LS_PREFIX from './utils/lsPrefix'; + +const LS_KEY = `${LS_PREFIX}::firstRun`; + +class OnboardingStore { + @observable isFirstRun; + + constructor () { + const isFirstRun = store.get(LS_KEY); + if (isFirstRun === undefined) { + // Set store property to true. + this.setIsFirstRun(true); + // Set localStorage to false, so that next time, isFirstRun will be + // false. + this.updateLS(); + } else { + this.setIsFirstRun(isFirstRun); + } + } + + @action setIsFirstRun = isFirstRun => (this.isFirstRun = isFirstRun); + + updateLS = () => store.set(LS_KEY, false); +} + +export default new OnboardingStore(); diff --git a/src/stores/index.js b/src/stores/index.js index d2346d8a..e8165599 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -5,6 +5,7 @@ import createAccountStore from './createAccountStore'; import healthStore from './healthStore'; +import firstRunStore from './firstRunStore'; import parityStore from './parityStore'; import signerStore from './signerStore'; import tokensStore from './tokensStore'; @@ -12,6 +13,7 @@ import tokensStore from './tokensStore'; export default { createAccountStore, healthStore, + firstRunStore, parityStore, signerStore, tokensStore diff --git a/src/stores/parityStore.js b/src/stores/parityStore.js index daf392d4..b5c7c9e5 100644 --- a/src/stores/parityStore.js +++ b/src/stores/parityStore.js @@ -9,10 +9,11 @@ import isElectron from 'is-electron'; import light from '@parity/light.js'; import store from 'store'; +import LS_PREFIX from './utils/lsPrefix'; + const electron = isElectron() ? window.require('electron') : null; -const LS_PREFIX = '__paritylight::'; -const LS_KEY = `${LS_PREFIX}secureToken`; +const LS_KEY = `${LS_PREFIX}::secureToken`; class ParityStore { @observable downloadProgress = 0; diff --git a/src/stores/tokensStore.js b/src/stores/tokensStore.js index 6778956a..562b0bcc 100644 --- a/src/stores/tokensStore.js +++ b/src/stores/tokensStore.js @@ -9,20 +9,19 @@ import { combineLatest } from 'rxjs'; import store from 'store'; import ethereumIcon from '../assets/img/tokens/ethereum.png'; +import LS_PREFIX from './utils/lsPrefix'; -const LS_PREFIX = '__paritylight::tokens'; +const LS_KEY = `${LS_PREFIX}::tokens`; class TokensStore { @observable tokens = new Map(); constructor () { - combineLatest( - chainName$(), - defaultAccount$() - ).subscribe(([chainName, defaultAccount]) => - // Refetch token from localStorage everytime we have a new chainName - // (shouldn't happen) or the user selects a new account - this.fetchTokensFromDb(chainName, defaultAccount) + combineLatest(chainName$(), defaultAccount$()).subscribe( + ([chainName, defaultAccount]) => + // Refetch token from localStorage everytime we have a new chainName + // (shouldn't happen) or the user selects a new account + this.fetchTokensFromDb(chainName, defaultAccount) ); } @@ -36,7 +35,7 @@ class TokensStore { fetchTokensFromDb = async (chainName, defaultAccount) => { // Set the localStorage key, we have one key per chain per account, in this // format: __paritylight::tokens::0x123::kovan - this.lsKey = `${LS_PREFIX}::${defaultAccount}::${chainName}`; + this.lsKey = `${LS_KEY}::${defaultAccount}::${chainName}`; // Now we fetch the tokens from the localStorage const tokens = store.get(this.lsKey); diff --git a/src/stores/utils/lsPrefix.js b/src/stores/utils/lsPrefix.js new file mode 100644 index 00000000..52c6efcf --- /dev/null +++ b/src/stores/utils/lsPrefix.js @@ -0,0 +1,7 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +// All keys in localStorage are prefixed with: +export default '__paritylight'; -- GitLab From f202e0df9793b4f5a32ba87232bd6609e1cc7cb5 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 7 Jun 2018 17:54:57 +0200 Subject: [PATCH 3/4] Put more stuff into onboardingStore --- .../AccountConfirm/AccountConfirm.js | 8 +-- src/App/App.js | 21 +------ src/Onboarding/Onboarding.js | 22 +++---- src/stores/firstRunStore.js | 34 ---------- src/stores/index.js | 4 +- src/stores/onboardingStore.js | 62 +++++++++++++++++++ src/stores/signerStore.js | 2 +- 7 files changed, 81 insertions(+), 72 deletions(-) delete mode 100644 src/stores/firstRunStore.js create mode 100644 src/stores/onboardingStore.js diff --git a/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js b/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js index a5fbaf20..2f6793cf 100644 --- a/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js +++ b/src/Accounts/CreateAccount/AccountConfirm/AccountConfirm.js @@ -8,20 +8,20 @@ import { inject, observer } from 'mobx-react'; import CreateAccountHeader from '../CreateAccountHeader'; -@inject('createAccountStore', 'firstRunStore') +@inject('createAccountStore', 'onboardingStore') @observer class AccountConfirm extends Component { handleSubmit = () => { const { createAccountStore: { saveAccountToParity }, history, - firstRunStore + onboardingStore } = this.props; // If we were onboarding, set isFirstRun to false, so that we quit // onboarding. - if (firstRunStore.isFirstRun) { - firstRunStore.setIsFirstRun(false); + if (onboardingStore.isFirstRun) { + onboardingStore.setIsFirstRun(false); } saveAccountToParity().then(() => history.push('/accounts')); diff --git a/src/App/App.js b/src/App/App.js index dd3b9372..d5197696 100644 --- a/src/App/App.js +++ b/src/App/App.js @@ -4,7 +4,6 @@ // SPDX-License-Identifier: MIT import React, { Component } from 'react'; -import { accounts$ } from '@parity/light.js'; import { BrowserRouter, MemoryRouter, @@ -15,7 +14,6 @@ import { import { inject, observer } from 'mobx-react'; import Accounts from '../Accounts'; -import light from '../hoc'; import Onboarding from '../Onboarding'; import Overlay from '../Overlay'; import Receive from '../Receive'; @@ -31,10 +29,7 @@ import './App.css'; const Router = process.env.NODE_ENV === 'production' ? MemoryRouter : BrowserRouter; -@light({ - accounts: accounts$ -}) -@inject('healthStore', 'firstRunStore') +@inject('healthStore', 'onboardingStore') @observer class App extends Component { render () { @@ -59,23 +54,11 @@ class App extends Component { */ renderScreen () { const { - accounts, - firstRunStore, + onboardingStore: { isOnboarding }, healthStore: { health: { status } } } = this.props; - const { isFirstRun } = firstRunStore; - - // We show the onboarding process if: - // - either it's the 1st time the user runs this app - // - or the user has 0 account - const isOnboarding = - // If either of the two is undefined, then it means we're still fetching. - // This doesn't count as onboarding. - accounts === undefined || isFirstRun === undefined - ? false - : isFirstRun || !accounts.length; // If we are onboarding, then never show the Overlay. On the other hand, if // we're not onboarding, show the Overlay whenever we have an issue. diff --git a/src/Onboarding/Onboarding.js b/src/Onboarding/Onboarding.js index 1c4dc2a5..40b8d2cc 100644 --- a/src/Onboarding/Onboarding.js +++ b/src/Onboarding/Onboarding.js @@ -3,30 +3,28 @@ // // SPDX-License-Identifier: MIT -import React, { PureComponent } from 'react'; -import { accounts$ } from '@parity/light.js'; -import { inject } from 'mobx-react'; +import React, { Component } from 'react'; +import { inject, observer } from 'mobx-react'; import { Link } from 'react-router-dom'; import Health from '../Health'; -import light from '../hoc'; -@light({ - accounts: accounts$ -}) -@inject('firstRunStore') -class Onboarding extends PureComponent { +@inject('onboardingStore') +@observer +class Onboarding extends Component { handleFirstRun = () => { // Not first run anymore after clicking Start - this.props.firstRunStore.setIsFirstRun(false); + this.props.onboardingStore.setIsFirstRun(false); }; render () { - const { accounts } = this.props; + const { + onboardingStore: { hasAccounts } + } = this.props; return (
This is the onboarding page.
- {accounts && accounts.length ? ( + {hasAccounts ? ( Start diff --git a/src/stores/firstRunStore.js b/src/stores/firstRunStore.js deleted file mode 100644 index 19cfe074..00000000 --- a/src/stores/firstRunStore.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. -// -// SPDX-License-Identifier: MIT - -import { action, observable } from 'mobx'; -import store from 'store'; - -import LS_PREFIX from './utils/lsPrefix'; - -const LS_KEY = `${LS_PREFIX}::firstRun`; - -class OnboardingStore { - @observable isFirstRun; - - constructor () { - const isFirstRun = store.get(LS_KEY); - if (isFirstRun === undefined) { - // Set store property to true. - this.setIsFirstRun(true); - // Set localStorage to false, so that next time, isFirstRun will be - // false. - this.updateLS(); - } else { - this.setIsFirstRun(isFirstRun); - } - } - - @action setIsFirstRun = isFirstRun => (this.isFirstRun = isFirstRun); - - updateLS = () => store.set(LS_KEY, false); -} - -export default new OnboardingStore(); diff --git a/src/stores/index.js b/src/stores/index.js index e8165599..16f1178c 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -5,7 +5,7 @@ import createAccountStore from './createAccountStore'; import healthStore from './healthStore'; -import firstRunStore from './firstRunStore'; +import onboardingStore from './onboardingStore'; import parityStore from './parityStore'; import signerStore from './signerStore'; import tokensStore from './tokensStore'; @@ -13,7 +13,7 @@ import tokensStore from './tokensStore'; export default { createAccountStore, healthStore, - firstRunStore, + onboardingStore, parityStore, signerStore, tokensStore diff --git a/src/stores/onboardingStore.js b/src/stores/onboardingStore.js new file mode 100644 index 00000000..fc878ecd --- /dev/null +++ b/src/stores/onboardingStore.js @@ -0,0 +1,62 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. +// +// SPDX-License-Identifier: MIT + +import { accountsInfo$ } from '@parity/light.js'; +import { action, computed, observable } from 'mobx'; +import { map } from 'rxjs/operators'; +import store from 'store'; + +import LS_PREFIX from './utils/lsPrefix'; + +const LS_KEY = `${LS_PREFIX}::firstRun`; + +class OnboardingStore { + @observable hasAccounts; // If the user has at least 1 account or not + @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); + } + + accountsInfo$() + .pipe(map(accounts => Object.keys(accounts).length > 0)) + .subscribe(this.setHasAccounts); + } + + /** + * We show the onboarding process if: + * - either it's the 1st time the user runs this app + * - or the user has 0 account + */ + @computed + get isOnboarding () { + // If either of the two is undefined, then it means we're still fetching. + // This doesn't count as onboarding. + return this.hasAccounts === undefined || this.isFirstRun === undefined + ? false + : !this.hasAccounts || this.isFirstRun; + } + + @action + setHasAccounts = hasAccounts => { + this.hasAccounts = hasAccounts; + }; + + @action + setIsFirstRun = isFirstRun => { + this.isFirstRun = isFirstRun; + this.updateLS(); + }; + + updateLS = () => store.set(LS_KEY, this.isFirstRun); +} + +export default new OnboardingStore(); diff --git a/src/stores/signerStore.js b/src/stores/signerStore.js index 785cca7a..dcf8bc39 100644 --- a/src/stores/signerStore.js +++ b/src/stores/signerStore.js @@ -19,7 +19,7 @@ class SignerStore { // TODO This .on() is not working, so we poll every second // this.api.on('connected', this.subscribePending); this.interval = setInterval(() => { - if (parityStore.isApiConnected) { + if (parityStore.isApiConnected && this.api) { this.subscribePending(); clearInterval(this.interval); } -- GitLab From f29272c766b03e8c212a5a2d803e21bbe6571a15 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 7 Jun 2018 17:59:55 +0200 Subject: [PATCH 4/4] Don't always regenerate new address --- .../CreateAccount/AccountName/AccountName.js | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Accounts/CreateAccount/AccountName/AccountName.js b/src/Accounts/CreateAccount/AccountName/AccountName.js index 6d9b7fde..fe20e3ba 100644 --- a/src/Accounts/CreateAccount/AccountName/AccountName.js +++ b/src/Accounts/CreateAccount/AccountName/AccountName.js @@ -13,7 +13,11 @@ import CreateAccountHeader from '../CreateAccountHeader'; @observer class AccountName extends Component { componentDidMount () { - this.props.createAccountStore.generateNewAccount(); + const { createAccountStore } = this.props; + // Generate a new public address if there's none yet + if (!createAccountStore.address) { + createAccountStore.generateNewAccount(); + } } handleChangeName = ({ target: { value } }) => @@ -28,12 +32,12 @@ class AccountName extends Component { return (
- {address && + {address && (
- {!isImport && + {!isImport && (
-
} +
+ )}

Please give this account a name:

@@ -55,17 +60,20 @@ class AccountName extends Component { />
-
} + + )} ); } -- GitLab