Browse Source

Merge pull request #529 from meriadec/polishes/stuff

Polishes/stuff
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
fb7501f700
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/components/TopBar/ActivityIndicator.js
  2. 8
      src/components/WithFeesAPI.js
  3. 6
      src/components/base/Modal/ModalBody.js
  4. 1
      src/components/modals/ImportAccounts/index.js
  5. 1
      src/components/modals/ImportAccounts/steps/01-step-choose-currency.js
  6. 37
      src/components/modals/PrevButton.js
  7. 2
      src/components/modals/Receive/01-step-account.js
  8. 4
      src/components/modals/Receive/index.js
  9. 1
      src/components/modals/Send/01-step-amount.js
  10. 4
      src/components/modals/Send/RecipientField.js
  11. 4
      src/components/modals/Send/SendModalBody.js
  12. 4
      src/components/modals/Send/index.js
  13. 9
      src/reducers/settings.js

7
src/components/TopBar/ActivityIndicator.js

@ -53,12 +53,9 @@ class ActivityIndicatorInner extends Component<Props, State> {
isGlobalSyncStatePending: nextProps.isGlobalSyncStatePending, isGlobalSyncStatePending: nextProps.isGlobalSyncStatePending,
} }
if (prevState.hasClicked && !nextProps.isGlobalSyncStatePending) {
nextState.hasClicked = false
}
if (prevState.isGlobalSyncStatePending && !nextProps.isGlobalSyncStatePending) { if (prevState.isGlobalSyncStatePending && !nextProps.isGlobalSyncStatePending) {
nextState.isFirstSync = false nextState.isFirstSync = false
nextState.hasClicked = false
} }
return nextState return nextState
@ -92,7 +89,7 @@ class ActivityIndicatorInner extends Component<Props, State> {
)} )}
</Rotating> </Rotating>
<Box <Box
ml={2} ml={1}
ff="Open Sans|SemiBold" ff="Open Sans|SemiBold"
color={isError ? 'alertRed' : undefined} color={isError ? 'alertRed' : undefined}
fontSize={4} fontSize={4}

8
src/components/WithFeesAPI.js

@ -21,13 +21,17 @@ export default class WithFeesAPI extends Component<
componentDidMount() { componentDidMount() {
this.load() this.load()
} }
componentWillUnmount() {
this._unmounted = true
}
_unmounted = false
async load() { async load() {
const { currency } = this.props const { currency } = this.props
try { try {
const fees = await getEstimatedFees(currency) const fees = await getEstimatedFees(currency)
this.setState({ error: null, fees }) if (!this._unmounted) this.setState({ error: null, fees })
} catch (error) { } catch (error) {
this.setState({ error, fees: null }) if (!this._unmounted) this.setState({ error, fees: null })
} }
} }
render() { render() {

6
src/components/base/Modal/ModalBody.js

@ -55,13 +55,13 @@ class ModalBody extends PureComponent<Props, State> {
} }
const CloseContainer = styled(Box).attrs({ const CloseContainer = styled(Box).attrs({
p: 2, p: 4,
color: 'fog', color: 'fog',
})` })`
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
top: 25px; top: 0;
right: 10px; right: 0;
z-index: 1; z-index: 1;
&:hover { &:hover {

1
src/components/modals/ImportAccounts/index.js

@ -70,7 +70,6 @@ type Props = {
} }
type StepId = 'chooseCurrency' | 'connectDevice' | 'import' | 'finish' type StepId = 'chooseCurrency' | 'connectDevice' | 'import' | 'finish'
type ScanStatus = 'idle' | 'scanning' | 'error' | 'finished' type ScanStatus = 'idle' | 'scanning' | 'error' | 'finished'
type State = { type State = {

1
src/components/modals/ImportAccounts/steps/01-step-choose-currency.js

@ -12,6 +12,7 @@ import type { StepProps } from '../index'
function StepChooseCurrency({ currency, setState }: StepProps) { function StepChooseCurrency({ currency, setState }: StepProps) {
return ( return (
<SelectCurrency <SelectCurrency
autoFocus
onChange={currency => { onChange={currency => {
setState({ setState({
currency: isArray(currency) && currency.length === 0 ? null : currency, currency: isArray(currency) && currency.length === 0 ? null : currency,

37
src/components/modals/PrevButton.js

@ -1,37 +0,0 @@
// @flow
import React from 'react'
import { translate } from 'react-i18next'
import styled from 'styled-components'
import type { T } from 'types/common'
import Button from 'components/base/Button'
import Box from 'components/base/Box'
import IconAngleLeft from 'icons/AngleLeft'
const Wrapper = styled(Button).attrs({
fontSize: 4,
ml: 4,
})`
left: 0;
margin-top: -18px;
position: absolute;
top: 50%;
`
type Props = {
t: T,
}
const PrevButton = ({ t, ...props }: Props) => (
<Wrapper {...props}>
<Box horizontal alignItems="center">
<IconAngleLeft size={16} />
{t('app:common.back')}
</Box>
</Wrapper>
)
export default translate()(PrevButton)

2
src/components/modals/Receive/01-step-account.js

@ -18,6 +18,6 @@ type Props = {
export default (props: Props) => ( export default (props: Props) => (
<Box flow={1}> <Box flow={1}>
<Label>{props.t('app:receive.steps.chooseAccount.label')}</Label> <Label>{props.t('app:receive.steps.chooseAccount.label')}</Label>
<SelectAccount onChange={props.onChangeAccount} value={props.account} /> <SelectAccount autoFocus onChange={props.onChangeAccount} value={props.account} />
</Box> </Box>
) )

4
src/components/modals/Receive/index.js

@ -17,7 +17,6 @@ import Box from 'components/base/Box'
import Breadcrumb from 'components/Breadcrumb' import Breadcrumb from 'components/Breadcrumb'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Modal, { ModalBody, ModalTitle, ModalContent, ModalFooter } from 'components/base/Modal' import Modal, { ModalBody, ModalTitle, ModalContent, ModalFooter } from 'components/base/Modal'
import PrevButton from 'components/modals/PrevButton'
import StepConnectDevice from 'components/modals/StepConnectDevice' import StepConnectDevice from 'components/modals/StepConnectDevice'
import StepAccount from './01-step-account' import StepAccount from './01-step-account'
@ -318,8 +317,7 @@ class ReceiveModal extends PureComponent<Props, State> {
<ModalBody onClose={canClose ? onClose : undefined}> <ModalBody onClose={canClose ? onClose : undefined}>
<SyncSkipUnderPriority priority={9} /> <SyncSkipUnderPriority priority={9} />
{account && <SyncOneAccountOnMount priority={10} accountId={account.id} />} {account && <SyncOneAccountOnMount priority={10} accountId={account.id} />}
<ModalTitle> <ModalTitle onBack={canPrev ? this.handlePrevStep : undefined}>
{canPrev && <PrevButton onClick={this.handlePrevStep} />}
{t('app:receive.title')} {t('app:receive.title')}
</ModalTitle> </ModalTitle>
<ModalContent> <ModalContent>

1
src/components/modals/Send/01-step-amount.js

@ -63,6 +63,7 @@ function StepAmount({
{account && bridge && transaction ? ( {account && bridge && transaction ? (
<Fragment key={account.id}> <Fragment key={account.id}>
<RecipientField <RecipientField
autoFocus
account={account} account={account}
bridge={bridge} bridge={bridge}
transaction={transaction} transaction={transaction}

4
src/components/modals/Send/RecipientField.js

@ -14,6 +14,7 @@ type Props<Transaction> = {
bridge: WalletBridge<Transaction>, bridge: WalletBridge<Transaction>,
transaction: Transaction, transaction: Transaction,
onChangeTransaction: Transaction => void, onChangeTransaction: Transaction => void,
autoFocus?: boolean,
} }
class RecipientField<Transaction> extends Component<Props<Transaction>, { isValid: boolean }> { class RecipientField<Transaction> extends Component<Props<Transaction>, { isValid: boolean }> {
@ -59,7 +60,7 @@ class RecipientField<Transaction> extends Component<Props<Transaction>, { isVali
} }
render() { render() {
const { bridge, account, transaction, t } = this.props const { bridge, account, transaction, t, autoFocus } = this.props
const { isValid } = this.state const { isValid } = this.state
const value = bridge.getTransactionRecipient(account, transaction) const value = bridge.getTransactionRecipient(account, transaction)
return ( return (
@ -69,6 +70,7 @@ class RecipientField<Transaction> extends Component<Props<Transaction>, { isVali
<LabelInfoTooltip ml={1} text={t('app:send.steps.amount.recipientAddress')} /> <LabelInfoTooltip ml={1} text={t('app:send.steps.amount.recipientAddress')} />
</Label> </Label>
<RecipientAddress <RecipientAddress
autoFocus={autoFocus}
withQrCode withQrCode
error={!value || isValid ? null : `This is not a valid ${account.currency.name} address`} error={!value || isValid ? null : `This is not a valid ${account.currency.name} address`}
value={value} value={value}

4
src/components/modals/Send/SendModalBody.js

@ -20,7 +20,6 @@ import PollCounterValuesOnMount from 'components/PollCounterValuesOnMount'
import Breadcrumb from 'components/Breadcrumb' import Breadcrumb from 'components/Breadcrumb'
import { ModalBody, ModalTitle, ModalContent } from 'components/base/Modal' import { ModalBody, ModalTitle, ModalContent } from 'components/base/Modal'
import PrevButton from 'components/modals/PrevButton'
import StepConnectDevice from 'components/modals/StepConnectDevice' import StepConnectDevice from 'components/modals/StepConnectDevice'
import ChildSwitch from 'components/base/ChildSwitch' import ChildSwitch from 'components/base/ChildSwitch'
import SyncSkipUnderPriority from 'components/SyncSkipUnderPriority' import SyncSkipUnderPriority from 'components/SyncSkipUnderPriority'
@ -279,8 +278,7 @@ class SendModalBody extends PureComponent<Props, State<*>> {
<SyncSkipUnderPriority priority={80} /> <SyncSkipUnderPriority priority={80} />
{account && <SyncOneAccountOnMount priority={81} accountId={account.id} />} {account && <SyncOneAccountOnMount priority={81} accountId={account.id} />}
<ModalTitle> <ModalTitle onBack={canPrev ? this.onPrevStep : undefined}>
{canPrev && <PrevButton onClick={this.onPrevStep} />}
{t('app:send.title')} {t('app:send.title')}
</ModalTitle> </ModalTitle>

4
src/components/modals/Send/index.js

@ -1,10 +1,10 @@
// @flow // @flow
import React, { PureComponent } from 'react' import React, { Component } from 'react'
import { MODAL_SEND } from 'config/constants' import { MODAL_SEND } from 'config/constants'
import Modal from 'components/base/Modal' import Modal from 'components/base/Modal'
import SendModalBody from './SendModalBody' import SendModalBody from './SendModalBody'
class SendModal extends PureComponent<{}> { class SendModal extends Component<void> {
render() { render() {
return ( return (
<Modal <Modal

9
src/reducers/settings.js

@ -177,12 +177,19 @@ export const getOrderAccounts = (state: State) => state.settings.orderAccounts
export const areSettingsLoaded = (state: State) => state.settings.loaded export const areSettingsLoaded = (state: State) => state.settings.loaded
// TODO: avoid this memoize hack (i thought reselect was doing it for us)
const __memoizedCurrencySettingsLocaleValues = {}
export const currencySettingsLocaleSelector = ( export const currencySettingsLocaleSelector = (
settings: SettingsState, settings: SettingsState,
currency: Currency, currency: Currency,
): CurrencySettings => { ): CurrencySettings => {
if (__memoizedCurrencySettingsLocaleValues[currency.id]) {
return __memoizedCurrencySettingsLocaleValues[currency.id]
}
const currencySettings = settings.currenciesSettings[currency.id] const currencySettings = settings.currenciesSettings[currency.id]
return { ...defaultsForCurrency(currency), ...currencySettings } const val = { ...defaultsForCurrency(currency), ...currencySettings }
__memoizedCurrencySettingsLocaleValues[currency.id] = val
return val
} }
type CSS = Selector<*, { currency: CryptoCurrency }, CurrencySettings> type CSS = Selector<*, { currency: CryptoCurrency }, CurrencySettings>

Loading…
Cancel
Save