diff --git a/src/components/CryptoCurrencyIcon.js b/src/components/CryptoCurrencyIcon.js index 192c8b64..8264a0b4 100644 --- a/src/components/CryptoCurrencyIcon.js +++ b/src/components/CryptoCurrencyIcon.js @@ -6,7 +6,7 @@ import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' type Props = { currency: CryptoCurrency, size: number, - color: string, + color?: string, } class CryptoCurrencyIcon extends PureComponent { diff --git a/src/components/SideBar/index.js b/src/components/SideBar/index.js index b78c5065..53b16d26 100644 --- a/src/components/SideBar/index.js +++ b/src/components/SideBar/index.js @@ -79,7 +79,11 @@ class SideBar extends PureComponent { {t('sidebar:menu')} - } linkTo="/" highlight={updateStatus === 'downloaded'}> + } + linkTo="/" + highlight={updateStatus === 'downloaded'} + > {t('dashboard:title')} } modal={MODAL_SEND}> diff --git a/src/components/base/FormattedVal/__tests__/__snapshots__/FormattedVal.test.js.snap b/src/components/base/FormattedVal/__tests__/__snapshots__/FormattedVal.test.js.snap index 45d28048..6d59e715 100644 --- a/src/components/base/FormattedVal/__tests__/__snapshots__/FormattedVal.test.js.snap +++ b/src/components/base/FormattedVal/__tests__/__snapshots__/FormattedVal.test.js.snap @@ -2,7 +2,7 @@ exports[`components FormattedVal renders a formatted val 1`] = `
4 @@ -11,7 +11,7 @@ exports[`components FormattedVal renders a formatted val 1`] = ` exports[`components FormattedVal renders a percent 1`] = `
30 % @@ -20,7 +20,7 @@ exports[`components FormattedVal renders a percent 1`] = ` exports[`components FormattedVal shows code 1`] = `
BTC 4 @@ -29,7 +29,7 @@ exports[`components FormattedVal shows code 1`] = ` exports[`components FormattedVal shows sign 1`] = `
+ 4 @@ -38,7 +38,7 @@ exports[`components FormattedVal shows sign 1`] = ` exports[`components FormattedVal shows sign 2`] = `
- 4 diff --git a/src/components/base/Input/index.js b/src/components/base/Input/index.js index d2d09747..6e187df4 100644 --- a/src/components/base/Input/index.js +++ b/src/components/base/Input/index.js @@ -102,7 +102,7 @@ class Input extends PureComponent { } } - handleKeyDown = (e: SyntheticInputEvent) => { + handleKeyDown = (e: SyntheticKeyboardEvent) => { // handle enter key if (e.which === 13) { const { onEnter } = this.props @@ -137,8 +137,8 @@ class Input extends PureComponent { } handleSelectEverything = () => { - this._input.setSelectionRange(0, this._input.value.length) - this._input.focus() + this._input && this._input.setSelectionRange(0, this._input.value.length) + this._input && this._input.focus() } _input = null diff --git a/src/components/base/Radio/index.js b/src/components/base/Radio/index.js index c63c8a09..4d52f722 100644 --- a/src/components/base/Radio/index.js +++ b/src/components/base/Radio/index.js @@ -66,8 +66,4 @@ function Radio(props: Props) { return onChange && onChange(!isChecked)} /> } -Radio.defaultProps = { - onChange: null, -} - export default Radio diff --git a/src/components/modals/ImportAccounts/AccountRow.js b/src/components/modals/ImportAccounts/AccountRow.js index 634ee51d..99251f28 100644 --- a/src/components/modals/ImportAccounts/AccountRow.js +++ b/src/components/modals/ImportAccounts/AccountRow.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react' import styled from 'styled-components' +import type { Account } from '@ledgerhq/live-common/lib/types' import { darken } from 'styles/helpers' @@ -32,20 +33,20 @@ export default class AccountRow extends PureComponent { accountNameCopy: '', } - componentDidUpdate(prevProps, prevState) { + componentDidUpdate(prevProps: Props, prevState: State) { const startedEditing = !prevState.isEditing && this.state.isEditing if (startedEditing) { - this._input.handleSelectEverything() + this._input && this._input.handleSelectEverything() } } - handleEditClick = e => { + handleEditClick = (e: SyntheticEvent) => { this.handlePreventSubmit(e) const { account } = this.props this.setState({ isEditing: true, accountNameCopy: account.name }) } - handleSubmitName = e => { + handleSubmitName = (e: SyntheticEvent) => { this.handlePreventSubmit(e) const { account, onAccountUpdate, isChecked, onClick } = this.props const { accountNameCopy } = this.state @@ -57,13 +58,13 @@ export default class AccountRow extends PureComponent { } } - handlePreventSubmit = e => { + handlePreventSubmit = (e: SyntheticEvent) => { // prevent account row to be submitted e.preventDefault() e.stopPropagation() } - handleChangeName = accountNameCopy => this.setState({ accountNameCopy }) + handleChangeName = (accountNameCopy: string) => this.setState({ accountNameCopy }) handleReset = () => this.setState({ isEditing: false, accountNameCopy: '' }) diff --git a/src/components/modals/ImportAccounts/index.js b/src/components/modals/ImportAccounts/index.js index 64ee5e09..e680a571 100644 --- a/src/components/modals/ImportAccounts/index.js +++ b/src/components/modals/ImportAccounts/index.js @@ -62,6 +62,8 @@ type Props = { t: T, currentDevice: ?Device, existingAccounts: Account[], + closeModal: string => void, + addAccount: Account => void, } type StepId = 'chooseCurrency' | 'connectDevice' | 'import' | 'finish' @@ -87,7 +89,7 @@ export type StepProps = { isAppOpened: boolean, transitionTo: StepId => void, setState: any => void, - onClickImport: void => void, + onClickImport: void => Promise, onCloseModal: void => void, // scan process @@ -114,6 +116,8 @@ const INITIAL_STATE = { currency: null, scannedAccounts: [], checkedAccountsIds: [], + err: null, + scanStatus: 'idle', } class ImportAccounts extends PureComponent { diff --git a/src/components/modals/ImportAccounts/steps/03-step-import.js b/src/components/modals/ImportAccounts/steps/03-step-import.js index 97dbdd68..a77e3dbe 100644 --- a/src/components/modals/ImportAccounts/steps/03-step-import.js +++ b/src/components/modals/ImportAccounts/steps/03-step-import.js @@ -1,6 +1,7 @@ // @flow import React, { PureComponent } from 'react' +import type { Account } from '@ledgerhq/live-common/lib/types' import { getBridgeForCurrency } from 'bridge' @@ -15,17 +16,17 @@ import type { StepProps } from '../index' class StepImport extends PureComponent { componentDidMount() { - console.log(`starting import...`) this.startScanAccountsDevice() } componentWillUnmount() { - console.log(`stopping import...`) if (this.scanSubscription) { this.scanSubscription.unsubscribe() } } + scanSubscription = null + startScanAccountsDevice() { const { currency, currentDevice, setState } = this.props try { @@ -79,7 +80,7 @@ class StepImport extends PureComponent { }) } - handleToggleAccount = account => { + handleToggleAccount = (account: Account) => { const { checkedAccountsIds, setState } = this.props const isChecked = checkedAccountsIds.find(id => id === account.id) !== undefined if (isChecked) { @@ -89,7 +90,7 @@ class StepImport extends PureComponent { } } - handleAccountUpdate = updatedAccount => { + handleAccountUpdate = (updatedAccount: Account) => { const { scannedAccounts, setState } = this.props setState({ scannedAccounts: scannedAccounts.map(account => { diff --git a/src/components/modals/ImportAccounts/steps/04-step-finish.js b/src/components/modals/ImportAccounts/steps/04-step-finish.js index 4ee03102..71eb7758 100644 --- a/src/components/modals/ImportAccounts/steps/04-step-finish.js +++ b/src/components/modals/ImportAccounts/steps/04-step-finish.js @@ -6,6 +6,8 @@ import Box from 'components/base/Box' import Button from 'components/base/Button' import IconCheckCircle from 'icons/CheckCircle' +import type { StepProps } from '../index' + function StepFinish({ onCloseModal }: StepProps) { return (