mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-02 20:30:54 +00:00
better parameter handling
This commit is contained in:
parent
d2f63becfa
commit
dcbdf2bfa1
@ -43,6 +43,7 @@ const RowAccountWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const RowAccount = ({
|
const RowAccount = ({
|
||||||
accountIndex, balance, url, isSelected = false,
|
accountIndex, balance, url, isSelected = false,
|
||||||
}) => (
|
}) => (
|
||||||
@ -62,6 +63,7 @@ const RowAccount = ({
|
|||||||
</RowAccountWrapper>
|
</RowAccountWrapper>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
|
|
||||||
RowAccount.propTypes = {
|
RowAccount.propTypes = {
|
||||||
accountIndex: PropTypes.number.isRequired,
|
accountIndex: PropTypes.number.isRequired,
|
||||||
url: PropTypes.string.isRequired,
|
url: PropTypes.string.isRequired,
|
||||||
@ -71,9 +73,6 @@ RowAccount.propTypes = {
|
|||||||
|
|
||||||
const AccountMenu = (props: Props): ?React$Element<string> => {
|
const AccountMenu = (props: Props): ?React$Element<string> => {
|
||||||
const selected = props.wallet.selectedDevice;
|
const selected = props.wallet.selectedDevice;
|
||||||
console.warn('selected', selected);
|
|
||||||
if (!selected) return null;
|
|
||||||
|
|
||||||
const { location } = props.router;
|
const { location } = props.router;
|
||||||
const urlParams = location.state;
|
const urlParams = location.state;
|
||||||
const { accounts } = props;
|
const { accounts } = props;
|
||||||
@ -81,8 +80,6 @@ const AccountMenu = (props: Props): ?React$Element<string> => {
|
|||||||
|
|
||||||
const { config } = props.localStorage;
|
const { config } = props.localStorage;
|
||||||
const selectedCoin = config.coins.find(c => c.network === location.state.network);
|
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 fiatRate = props.fiat.find(f => f.network === selectedCoin.network);
|
||||||
|
|
||||||
const deviceAccounts: Accounts = findDeviceAccounts(accounts, selected, location.state.network);
|
const deviceAccounts: Accounts = findDeviceAccounts(accounts, selected, location.state.network);
|
||||||
|
@ -129,7 +129,7 @@ class CoinMenu extends Component {
|
|||||||
textRight="(You will be redirected)"
|
textRight="(You will be redirected)"
|
||||||
/>
|
/>
|
||||||
{coins.map(coin => (
|
{coins.map(coin => (
|
||||||
<a href={coin.url}>
|
<a key={coin.url} href={coin.url}>
|
||||||
<RowCoin
|
<RowCoin
|
||||||
coin={{
|
coin={{
|
||||||
img: coin.image,
|
img: coin.image,
|
||||||
|
@ -4,11 +4,7 @@ import PropTypes from 'prop-types';
|
|||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { AccountMenu, CoinMenu, DeviceSelect, DeviceDropdown } from './NavigationMenu';
|
||||||
import type { TrezorDevice } from 'flowtype';
|
|
||||||
import {
|
|
||||||
AccountMenu, CoinMenu, DeviceSelect, DeviceDropdown,
|
|
||||||
} from './NavigationMenu';
|
|
||||||
import StickyContainer from './StickyContainer';
|
import StickyContainer from './StickyContainer';
|
||||||
|
|
||||||
const TransitionGroupWrapper = styled(TransitionGroup)`
|
const TransitionGroupWrapper = styled(TransitionGroup)`
|
||||||
@ -42,13 +38,15 @@ class LeftNavigation extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps() {
|
componentWillReceiveProps() {
|
||||||
|
const { deviceDropdownOpened } = this.props;
|
||||||
const { selectedDevice } = this.props.wallet;
|
const { selectedDevice } = this.props.wallet;
|
||||||
|
const { network } = this.props.location;
|
||||||
const hasFeatures = selectedDevice && selectedDevice.features;
|
const hasFeatures = selectedDevice && selectedDevice.features;
|
||||||
const deviceReady = hasFeatures && !selectedDevice.features.bootloader_mode && selectedDevice.features.initialized;
|
const deviceReady = hasFeatures && !selectedDevice.features.bootloader_mode && selectedDevice.features.initialized;
|
||||||
|
|
||||||
if (this.props.deviceDropdownOpened) {
|
if (deviceDropdownOpened) {
|
||||||
this.setState({ shouldRenderDeviceSelection: true });
|
this.setState({ shouldRenderDeviceSelection: true });
|
||||||
} else if (this.props.location.network) {
|
} else if (network) {
|
||||||
this.setState({
|
this.setState({
|
||||||
shouldRenderDeviceSelection: false,
|
shouldRenderDeviceSelection: false,
|
||||||
animationType: 'slide-left',
|
animationType: 'slide-left',
|
||||||
@ -83,7 +81,8 @@ class LeftNavigation extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldRenderAccounts() {
|
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() {
|
shouldRenderCoins() {
|
||||||
@ -99,7 +98,7 @@ class LeftNavigation extends Component {
|
|||||||
<DeviceSelect {...this.props} />
|
<DeviceSelect {...this.props} />
|
||||||
<MenuWrapper>
|
<MenuWrapper>
|
||||||
{this.state.shouldRenderDeviceSelection && this.getMenuTransition(<DeviceDropdown {...this.props} />) }
|
{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} />}
|
{this.shouldRenderCoins && <CoinMenu key="coins" {...this.props} />}
|
||||||
</MenuWrapper>
|
</MenuWrapper>
|
||||||
<StickyBottom>
|
<StickyBottom>
|
||||||
|
Loading…
Reference in New Issue
Block a user