From 3ff6887c177d6921d9c5b436581f4847f563a634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Fri, 8 Jun 2018 10:19:45 +0200 Subject: [PATCH] optim a bit Operation render time --- src/components/OperationsList/Operation.js | 27 ++++++------------- .../OperationsList/OperationDate.js | 21 +++++++++++++++ src/components/OperationsList/index.js | 8 +++++- 3 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 src/components/OperationsList/OperationDate.js diff --git a/src/components/OperationsList/Operation.js b/src/components/OperationsList/Operation.js index 565a058b..1ed8c13a 100644 --- a/src/components/OperationsList/Operation.js +++ b/src/components/OperationsList/Operation.js @@ -4,7 +4,6 @@ import React, { PureComponent } from 'react' import { connect } from 'react-redux' import styled from 'styled-components' import { createStructuredSelector } from 'reselect' -import moment from 'moment' import noop from 'lodash/noop' import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react' import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/helpers/operation' @@ -17,10 +16,10 @@ import { currencySettingsForAccountSelector, marketIndicatorSelector } from 'red import { rgba, getMarketColor } from 'styles/helpers' import Box from 'components/base/Box' -import Text from 'components/base/Text' import CounterValue from 'components/CounterValue' import FormattedVal from 'components/base/FormattedVal' +import OperationDate from './OperationDate' import ConfirmationCheck from './ConfirmationCheck' const mapStateToProps = createStructuredSelector({ @@ -79,19 +78,6 @@ const AddressEllipsis = styled.div` white-space: nowrap; ` -const Day = styled(Text).attrs({ - color: 'dark', - fontSize: 3, - ff: 'Open Sans', -})` - letter-spacing: 0.3px; - text-transform: uppercase; -` - -const Hour = styled(Day).attrs({ - color: 'grey', -})`` - const Cell = styled(Box).attrs({ px: 4, horizontal: true, @@ -131,7 +117,6 @@ class OperationComponent extends PureComponent { marketIndicator, } = this.props const { unit, currency } = account - const time = moment(op.date) const Icon = getCryptoCurrencyIcon(account.currency) const amount = getOperationAmountNumber(op) const isNegative = amount < 0 @@ -149,7 +134,11 @@ class OperationComponent extends PureComponent { return ( onOperationClick({ operation: op, account, marketColor })} + onClick={() => { + // FIXME why passing down marketColor !? we should retrieve from store / .. + // it should just be onOperationClick(operation) + onOperationClick({ operation: op, account, marketColor }) + }} > { {t(`operationsList:${op.type}`)} - {time.format('HH:mm')} + {withAccount && @@ -208,7 +197,7 @@ class OperationComponent extends PureComponent { diff --git a/src/components/OperationsList/OperationDate.js b/src/components/OperationsList/OperationDate.js new file mode 100644 index 00000000..5f22d208 --- /dev/null +++ b/src/components/OperationsList/OperationDate.js @@ -0,0 +1,21 @@ +// @flow +import React, { PureComponent } from 'react' +import styled from 'styled-components' +import moment from 'moment' +import Text from 'components/base/Text' + +const Hour = styled(Text).attrs({ + color: 'grey', + fontSize: 3, + ff: 'Open Sans', +})` + letter-spacing: 0.3px; + text-transform: uppercase; +` + +export default class OperationDate extends PureComponent<{ date: Date }> { + render() { + const { date } = this.props + return {moment(date).format('HH:mm')} + } +} diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index 34f2334f..99c92683 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -160,4 +160,10 @@ export class OperationsList extends PureComponent { } } -export default compose(translate(), connect(null, mapDispatchToProps))(OperationsList) +export default compose( + translate(), + connect( + null, + mapDispatchToProps, + ), +)(OperationsList)