better parameter handling

pull/3/head
Vladimir Volek 6 years ago
parent d2f63becfa
commit dcbdf2bfa1

@ -43,6 +43,7 @@ const RowAccountWrapper = styled.div`
}
`}
`;
const RowAccount = ({
accountIndex, balance, url, isSelected = false,
}) => (
@ -62,6 +63,7 @@ const RowAccount = ({
</RowAccountWrapper>
</NavLink>
);
RowAccount.propTypes = {
accountIndex: PropTypes.number.isRequired,
url: PropTypes.string.isRequired,
@ -71,9 +73,6 @@ RowAccount.propTypes = {
const AccountMenu = (props: Props): ?React$Element<string> => {
const selected = props.wallet.selectedDevice;
console.warn('selected', selected);
if (!selected) return null;
const { location } = props.router;
const urlParams = location.state;
const { accounts } = props;
@ -81,8 +80,6 @@ const AccountMenu = (props: Props): ?React$Element<string> => {
const { config } = props.localStorage;
const selectedCoin = config.coins.find(c => c.network === location.state.network);
if (!selectedCoin) return;
const fiatRate = props.fiat.find(f => f.network === selectedCoin.network);
const deviceAccounts: Accounts = findDeviceAccounts(accounts, selected, location.state.network);

@ -129,7 +129,7 @@ class CoinMenu extends Component {
textRight="(You will be redirected)"
/>
{coins.map(coin => (
<a href={coin.url}>
<a key={coin.url} href={coin.url}>
<RowCoin
coin={{
img: coin.image,

@ -4,11 +4,7 @@ import PropTypes from 'prop-types';
import colors from 'config/colors';
import { TransitionGroup, CSSTransition } from 'react-transition-group';
import styled from 'styled-components';
import type { TrezorDevice } from 'flowtype';
import {
AccountMenu, CoinMenu, DeviceSelect, DeviceDropdown,
} from './NavigationMenu';
import { AccountMenu, CoinMenu, DeviceSelect, DeviceDropdown } from './NavigationMenu';
import StickyContainer from './StickyContainer';
const TransitionGroupWrapper = styled(TransitionGroup)`
@ -42,13 +38,15 @@ class LeftNavigation extends Component {
}
componentWillReceiveProps() {
const { deviceDropdownOpened } = this.props;
const { selectedDevice } = this.props.wallet;
const { network } = this.props.location;
const hasFeatures = selectedDevice && selectedDevice.features;
const deviceReady = hasFeatures && !selectedDevice.features.bootloader_mode && selectedDevice.features.initialized;
if (this.props.deviceDropdownOpened) {
if (deviceDropdownOpened) {
this.setState({ shouldRenderDeviceSelection: true });
} else if (this.props.location.network) {
} else if (network) {
this.setState({
shouldRenderDeviceSelection: false,
animationType: 'slide-left',
@ -83,7 +81,8 @@ class LeftNavigation extends Component {
}
shouldRenderAccounts() {
return !this.state.shouldRenderDeviceSelection && this.state.animationType === 'slide-left';
const { selectedDevice } = this.props.wallet;
return selectedDevice && !this.state.shouldRenderDeviceSelection && this.state.animationType === 'slide-left';
}
shouldRenderCoins() {
@ -99,7 +98,7 @@ class LeftNavigation extends Component {
<DeviceSelect {...this.props} />
<MenuWrapper>
{this.state.shouldRenderDeviceSelection && this.getMenuTransition(<DeviceDropdown {...this.props} />) }
{/* {this.shouldRenderAccounts && <AccountMenu key="accounts" {...this.props} />} */}
{/* {this.shouldRenderAccounts && this.getMenuTransition(<AccountMenu key="accounts" {...this.props} />)} */}
{this.shouldRenderCoins && <CoinMenu key="coins" {...this.props} />}
</MenuWrapper>
<StickyBottom>

Loading…
Cancel
Save