From 1c0aa0adc80da35106bf86425ed862615b14cd2e Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Tue, 9 Oct 2018 16:10:30 +0200 Subject: [PATCH] remove all references to SelectedAccount component --- .../components/SelectedAccount/index.js | 115 ------------------ .../Wallet/views/Account/Receive/Container.js | 19 +-- .../Wallet/views/Account/Send/Container.js | 19 +-- .../Send/components/AdvancedForm/index.js | 9 +- .../Wallet/views/Account/Summary/Container.js | 18 ++- 5 files changed, 25 insertions(+), 155 deletions(-) delete mode 100644 src/views/Wallet/components/SelectedAccount/index.js diff --git a/src/views/Wallet/components/SelectedAccount/index.js b/src/views/Wallet/components/SelectedAccount/index.js deleted file mode 100644 index 65e800f9..00000000 --- a/src/views/Wallet/components/SelectedAccount/index.js +++ /dev/null @@ -1,115 +0,0 @@ -/* @flow */ -import * as React from 'react'; -import { Notification } from 'components/Notification'; -import { reconnect } from 'actions/DiscoveryActions'; - -import type { State } from 'flowtype'; - -export type StateProps = { - className: string; - selectedAccount: $ElementType, - wallet: $ElementType, - blockchain: $ElementType, - children?: React.Node -} - -export type DispatchProps = { - blockchainReconnect: typeof reconnect; -} - -export type Props = StateProps & DispatchProps; - -const SelectedAccount = (props: Props) => { - const device = props.wallet.selectedDevice; - if (!device || !device.state) { - return (); - } - - const accountState = props.selectedAccount; - - const { - account, - discovery, - network, - } = accountState; - - // corner case: accountState didn't finish loading state after LOCATION_CHANGE action - if (!network) return (); - - const blockchain = props.blockchain.find(b => b.name === network.network); - if (blockchain && !blockchain.connected) { - return ( - { - await props.blockchainReconnect(network.network); - }, - }] - } - /> - ); - } - - // account not found (yet). checking why... - if (!account) { - if (!discovery || discovery.waitingForDevice) { - if (device.connected) { - // case 1: device is connected but discovery not started yet (probably waiting for auth) - if (device.available) { - return ( - - ); - } - // case 2: device is unavailable (created with different passphrase settings) account cannot be accessed - return ( - - ); - } - // case 3: device is disconnected - return ( - - ); - } if (discovery.completed) { - // case 5: account not found and discovery is completed - return ( - - ); - } - // case 6: discovery is not completed yet - return ( - - ); - } - - let notification: ?React$Element = null; - if (!device.connected) { - notification = ; - } else if (!device.available) { - notification = ; - } - - if (discovery && !discovery.completed && !notification) { - notification = ; - } - - return ( -
- { notification } - { props.children } -
- ); -}; - -export default SelectedAccount; \ No newline at end of file diff --git a/src/views/Wallet/views/Account/Receive/Container.js b/src/views/Wallet/views/Account/Receive/Container.js index 22f5eda6..27212056 100644 --- a/src/views/Wallet/views/Account/Receive/Container.js +++ b/src/views/Wallet/views/Account/Receive/Container.js @@ -2,41 +2,34 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { reconnect } from 'actions/DiscoveryActions'; import { showAddress } from 'actions/ReceiveActions'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { State, Dispatch } from 'flowtype'; -import type { - StateProps as BaseStateProps, - DispatchProps as BaseDispatchProps, -} from 'views/Wallet/components/SelectedAccount'; import Receive from './index'; type OwnProps = { } -type StateProps = BaseStateProps & { +type StateProps = { + selectedAccount: $ElementType, receive: $ElementType, modal: $ElementType, + wallet: $ElementType, } -type DispatchProps = BaseDispatchProps & { +type DispatchProps = { showAddress: typeof showAddress }; -export type Props = StateProps & BaseStateProps & DispatchProps & BaseDispatchProps; +export type Props = StateProps & DispatchProps; const mapStateToProps: MapStateToProps = (state: State): StateProps => ({ - className: 'receive', selectedAccount: state.selectedAccount, - wallet: state.wallet, - blockchain: state.blockchain, - receive: state.receive, modal: state.modal, + wallet: state.wallet, }); const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ - blockchainReconnect: bindActionCreators(reconnect, dispatch), showAddress: bindActionCreators(showAddress, dispatch), }); diff --git a/src/views/Wallet/views/Account/Send/Container.js b/src/views/Wallet/views/Account/Send/Container.js index 14135764..e282b52b 100644 --- a/src/views/Wallet/views/Account/Send/Container.js +++ b/src/views/Wallet/views/Account/Send/Container.js @@ -1,45 +1,38 @@ /* @flow */ - -import * as React from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { reconnect } from 'actions/DiscoveryActions'; import SendFormActions from 'actions/SendFormActions'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { State, Dispatch } from 'flowtype'; -import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from 'views/Wallet/components/SelectedAccount'; import AccountSend from './index'; type OwnProps = { } -export type StateProps = BaseStateProps & { +export type StateProps = { + selectedAccount: $ElementType, sendForm: $ElementType, + wallet: $ElementType, fiat: $ElementType, localStorage: $ElementType, - children?: React.Node; } -export type DispatchProps = BaseDispatchProps & { +export type DispatchProps = { sendFormActions: typeof SendFormActions, } -export type Props = StateProps & BaseStateProps & DispatchProps & BaseDispatchProps; +export type Props = StateProps & DispatchProps; const mapStateToProps: MapStateToProps = (state: State): StateProps => ({ - className: 'send-from', selectedAccount: state.selectedAccount, - wallet: state.wallet, - blockchain: state.blockchain, - sendForm: state.sendForm, + wallet: state.wallet, fiat: state.fiat, localStorage: state.localStorage, }); const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ - blockchainReconnect: bindActionCreators(reconnect, dispatch), sendFormActions: bindActionCreators(SendFormActions, dispatch), }); diff --git a/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js b/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js index cd3bb65b..14a15300 100644 --- a/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js +++ b/src/views/Wallet/views/Account/Send/components/AdvancedForm/index.js @@ -1,6 +1,6 @@ /* @flow */ -import React from 'react'; +import * as React from 'react'; import styled from 'styled-components'; import colors from 'config/colors'; @@ -8,10 +8,13 @@ import Input from 'components/inputs/Input'; import Textarea from 'components/Textarea'; import Tooltip from 'components/Tooltip'; import Icon from 'components/Icon'; -import Link from 'components/Link'; import ICONS from 'config/icons'; -import type { Props } from '../../Container'; +import type { Props as BaseProps } from '../../Container'; + +type Props = BaseProps & { + children: React.Node, +} // TODO: Decide on a small screen width for the whole app // and put it inside config/variables.js diff --git a/src/views/Wallet/views/Account/Summary/Container.js b/src/views/Wallet/views/Account/Summary/Container.js index 5163b737..18d18175 100644 --- a/src/views/Wallet/views/Account/Summary/Container.js +++ b/src/views/Wallet/views/Account/Summary/Container.js @@ -3,44 +3,40 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; -import { reconnect } from 'actions/DiscoveryActions'; import * as TokenActions from 'actions/TokenActions'; import type { State, Dispatch } from 'flowtype'; -import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from 'views/Wallet/components/SelectedAccount'; import Summary from './index'; type OwnProps = { } -type StateProps = BaseStateProps & { - tokens: $ElementType, +type StateProps = { + selectedAccount: $ElementType, summary: $ElementType, + wallet: $ElementType, + tokens: $ElementType, fiat: $ElementType, localStorage: $ElementType, }; -type DispatchProps = BaseDispatchProps & { +type DispatchProps = { addToken: typeof TokenActions.add, loadTokens: typeof TokenActions.load, removeToken: typeof TokenActions.remove, } -export type Props = StateProps & BaseStateProps & DispatchProps & BaseDispatchProps; +export type Props = StateProps & DispatchProps; const mapStateToProps: MapStateToProps = (state: State): StateProps => ({ - className: 'summary', selectedAccount: state.selectedAccount, + summary: state.summary, wallet: state.wallet, - blockchain: state.blockchain, - tokens: state.tokens, - summary: state.summary, fiat: state.fiat, localStorage: state.localStorage, }); const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ - blockchainReconnect: bindActionCreators(reconnect, dispatch), addToken: bindActionCreators(TokenActions.add, dispatch), loadTokens: bindActionCreators(TokenActions.load, dispatch), removeToken: bindActionCreators(TokenActions.remove, dispatch),