From 9671226036c46db7140da51d5ef9a2836c2c7435 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 10 Oct 2018 10:39:59 +0200 Subject: [PATCH] eslint fixes --- .eslintignore | 3 +- src/reducers/DevicesReducer.js | 1 - .../components/AccountMenu/index.js | 4 +-- .../components/Indicator/index.js | 33 ++++++++++++------- .../components/TopNavigationAccount/index.js | 19 ++++++++--- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/.eslintignore b/.eslintignore index ec297d25..be07de15 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,4 +3,5 @@ build build-devel coverage node_modules -src/flowtype/npm \ No newline at end of file +src/flowtype/npm +**/_old/* \ No newline at end of file diff --git a/src/reducers/DevicesReducer.js b/src/reducers/DevicesReducer.js index 0ed79b82..d7ca930a 100644 --- a/src/reducers/DevicesReducer.js +++ b/src/reducers/DevicesReducer.js @@ -1,6 +1,5 @@ /* @flow */ - import { DEVICE } from 'trezor-connect'; import type { Device } from 'trezor-connect'; import * as CONNECT from 'actions/constants/TrezorConnect'; diff --git a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js index 1c238302..ba6cf83a 100644 --- a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js @@ -107,7 +107,7 @@ const DiscoveryLoadingText = styled.span` `; // TODO: Refactorize deviceStatus & selectedAccounts -const AccountMenu = (props: Props): ?React$Element => { +const AccountMenu = (props: Props) => { const selected = props.wallet.selectedDevice; const { location } = props.router; const urlParams = location.state; @@ -117,7 +117,7 @@ const AccountMenu = (props: Props): ?React$Element => { const { config } = props.localStorage; const selectedCoin = config.coins.find(c => c.network === location.state.network); - if (!selected || !selectedCoin) return; + if (!selected || !selectedCoin) return null; const fiatRate = props.fiat.find(f => f.network === selectedCoin.network); diff --git a/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js b/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js index e3c40e90..95c93e28 100644 --- a/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js @@ -1,7 +1,20 @@ +/* @flow */ + import styled from 'styled-components'; import colors from 'config/colors'; import React, { Component } from 'react'; +type Props = { + pathname: string; +} + +type State = { + style: { + width: number; + left: number; + } +} + const Wrapper = styled.div` position: absolute; bottom: 0px; @@ -13,8 +26,6 @@ const Wrapper = styled.div` `; class Indicator extends Component { - reposition: () => void; - constructor(props: Props) { super(props); @@ -28,25 +39,19 @@ class Indicator extends Component { this.reposition = this.reposition.bind(this); } - state: State; - - handleResize() { + componentDidMount() { this.reposition(); + window.addEventListener('resize', this.reposition, false); } - componentDidMount() { + componentDidUpdate() { this.reposition(); - window.addEventListener('resize', this.reposition, false); } componentWillUnmount() { window.removeEventListener('resize', this.reposition, false); } - componentDidUpdate() { - this.reposition(); - } - reposition() { const tabs = document.querySelector('.account-tabs'); if (!tabs) return; @@ -66,6 +71,12 @@ class Indicator extends Component { } } + reposition: () => void; + + handleResize() { + this.reposition(); + } + render() { return ( { this.props.pathname } diff --git a/src/views/Wallet/components/TopNavigationAccount/index.js b/src/views/Wallet/components/TopNavigationAccount/index.js index 17058116..aef26440 100644 --- a/src/views/Wallet/components/TopNavigationAccount/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/index.js @@ -1,10 +1,19 @@ +/* @flow */ + import styled from 'styled-components'; import React from 'react'; import { FONT_SIZE } from 'config/variables'; import { NavLink } from 'react-router-dom'; import colors from 'config/colors'; + +import type { Location } from 'react-router'; + import Indicator from './components/Indicator'; +type Props = { + location: Location; +}; + const Wrapper = styled.div` position: relative; display: flex; @@ -39,9 +48,11 @@ const StyledNavLink = styled(NavLink)` `; -const TopNavigationAccount = (props) => { - const urlParams = props.match.params; - const basePath = `/device/${urlParams.device}/network/${urlParams.network}/account/${urlParams.account}`; +const TopNavigationAccount = (props: Props) => { + const { state, pathname } = props.location; + if (!state) return null; + + const basePath = `/device/${state.device}/network/${state.network}/account/${state.account}`; return ( @@ -49,7 +60,7 @@ const TopNavigationAccount = (props) => { Receive Send {/* Sign & Verify */} - + ); };