From 663729ea6297de3d2bc7ae130e06fe46f2813849 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Tue, 22 May 2018 19:43:26 +0200 Subject: [PATCH] Aside: implementation of wallet.selectedDevice --- src/js/components/wallet/aside/AccountSelection.js | 3 +-- src/js/components/wallet/aside/Aside.js | 3 +-- src/js/components/wallet/aside/DeviceSelection.js | 7 +++---- src/js/components/wallet/aside/index.js | 4 +++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/js/components/wallet/aside/AccountSelection.js b/src/js/components/wallet/aside/AccountSelection.js index 688b9fd6..eac6e722 100644 --- a/src/js/components/wallet/aside/AccountSelection.js +++ b/src/js/components/wallet/aside/AccountSelection.js @@ -6,7 +6,6 @@ import { Link, NavLink } from 'react-router-dom'; import BigNumber from 'bignumber.js'; import { findDeviceAccounts } from '~/js/reducers/AccountsReducer'; -import { findSelectedDevice } from '~/js/reducers/TrezorConnectReducer'; import Loader from '~/js/components/common/LoaderCircle'; import Tooltip from 'rc-tooltip'; @@ -15,7 +14,7 @@ import type { TrezorDevice, Accounts } from '~/flowtype'; const AccountSelection = (props: Props): ?React$Element => { - const selected = findSelectedDevice(props.connect); + const selected = props.wallet.selectedDevice; if (!selected) return null; const { location } = props.router; diff --git a/src/js/components/wallet/aside/Aside.js b/src/js/components/wallet/aside/Aside.js index c6a03a02..2c2a02ee 100644 --- a/src/js/components/wallet/aside/Aside.js +++ b/src/js/components/wallet/aside/Aside.js @@ -10,7 +10,6 @@ import { DeviceSelect, DeviceDropdown } from './DeviceSelection'; import AccountSelection from './AccountSelection'; import CoinSelection from './CoinSelection'; import StickyContainer from './StickyContainer'; -import { findSelectedDevice } from '~/js/reducers/TrezorConnectReducer'; import type { Props } from './index'; import type { TrezorDevice } from '~/flowtype'; @@ -41,7 +40,7 @@ const TransitionMenu = (props: TransitionMenuProps): React$Element => { - const selected: ?TrezorDevice = findSelectedDevice(props.connect); + const selected: ?TrezorDevice = props.wallet.selectedDevice; const { location } = props.router; if (location.pathname === '/' || !selected) return (); diff --git a/src/js/components/wallet/aside/DeviceSelection.js b/src/js/components/wallet/aside/DeviceSelection.js index bc7d71f5..f99ab0c0 100644 --- a/src/js/components/wallet/aside/DeviceSelection.js +++ b/src/js/components/wallet/aside/DeviceSelection.js @@ -5,8 +5,6 @@ import React, { Component } from 'react'; import Select from 'react-select'; import TrezorConnect from 'trezor-connect'; -import { findSelectedDevice } from '~/js/reducers/TrezorConnectReducer'; - import type { Props } from './index'; import type { TrezorDevice } from '~/flowtype'; @@ -14,7 +12,7 @@ export const DeviceSelect = (props: Props) => { const { devices, transport } = props.connect; - const selected: ?TrezorDevice = findSelectedDevice(props.connect); + const selected: ?TrezorDevice = props.wallet.selectedDevice; if (!selected) return null; let deviceStatus: string = "Connected"; @@ -139,7 +137,7 @@ export class DeviceDropdown extends Component { render() { const { devices, transport } = this.props.connect; - const selected: ?TrezorDevice = findSelectedDevice(this.props.connect); + const selected: ?TrezorDevice = this.props.wallet.selectedDevice; if (!selected) return; let webUsbButton = null; @@ -179,6 +177,7 @@ export class DeviceDropdown extends Component { } const deviceList = devices.map((dev, index) => { + console.warn("DEVEEE", dev, selected, dev === selected); if (dev === selected) return null; let deviceStatus: string = "Connected"; diff --git a/src/js/components/wallet/aside/index.js b/src/js/components/wallet/aside/index.js index a08a381c..8892225c 100644 --- a/src/js/components/wallet/aside/index.js +++ b/src/js/components/wallet/aside/index.js @@ -26,6 +26,7 @@ type StateProps = { fiat: $ElementType, localStorage: $ElementType, discovery: $ElementType, + wallet: $ElementType, } type DispatchProps = { @@ -48,7 +49,8 @@ const mapStateToProps: MapStateToProps = (state: St deviceDropdownOpened: state.wallet.dropdownOpened, fiat: state.fiat, localStorage: state.localStorage, - discovery: state.discovery + discovery: state.discovery, + wallet: state.wallet }; }