|
@ -1,16 +1,21 @@ |
|
|
// @flow
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
import React, { PureComponent, Fragment } from 'react' |
|
|
import React, { PureComponent, Fragment } from 'react' |
|
|
|
|
|
import { ipcRenderer } from 'electron' |
|
|
import { compose } from 'redux' |
|
|
import { compose } from 'redux' |
|
|
import { translate } from 'react-i18next' |
|
|
import { translate } from 'react-i18next' |
|
|
import { connect } from 'react-redux' |
|
|
import { connect } from 'react-redux' |
|
|
import { push } from 'react-router-redux' |
|
|
import { push } from 'react-router-redux' |
|
|
|
|
|
import { formatCurrencyUnit, getFiatUnit } from '@ledgerhq/currencies' |
|
|
|
|
|
|
|
|
import type { Account } from '@ledgerhq/wallet-common/lib/types' |
|
|
import type { Account } from '@ledgerhq/wallet-common/lib/types' |
|
|
|
|
|
|
|
|
import chunk from 'lodash/chunk' |
|
|
import chunk from 'lodash/chunk' |
|
|
|
|
|
|
|
|
import type { T } from 'types/common' |
|
|
import type { T } from 'types/common' |
|
|
|
|
|
|
|
|
|
|
|
import { colors } from 'styles/theme' |
|
|
|
|
|
|
|
|
import { getVisibleAccounts } from 'reducers/accounts' |
|
|
import { getVisibleAccounts } from 'reducers/accounts' |
|
|
import { getCounterValueCode } from 'reducers/settings' |
|
|
import { getCounterValueCode } from 'reducers/settings' |
|
|
|
|
|
|
|
@ -77,12 +82,32 @@ class DashboardPage extends PureComponent<Props, State> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleCalculateBalance = data => { |
|
|
|
|
|
const { counterValue } = this.props |
|
|
|
|
|
|
|
|
|
|
|
if (process.platform === 'darwin' && this._cacheBalance !== data.totalBalance) { |
|
|
|
|
|
this._cacheBalance = data.totalBalance |
|
|
|
|
|
|
|
|
|
|
|
ipcRenderer.send('touch-bar-update', { |
|
|
|
|
|
text: 'Total balance', |
|
|
|
|
|
color: colors.wallet, |
|
|
|
|
|
balance: { |
|
|
|
|
|
counterValue: formatCurrencyUnit(getFiatUnit(counterValue), data.totalBalance, { |
|
|
|
|
|
showCode: true, |
|
|
|
|
|
}), |
|
|
|
|
|
}, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
handleChangeSelectedTime = item => |
|
|
handleChangeSelectedTime = item => |
|
|
this.setState({ |
|
|
this.setState({ |
|
|
selectedTime: item.key, |
|
|
selectedTime: item.key, |
|
|
daysCount: item.value, |
|
|
daysCount: item.value, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
_cacheBalance = null |
|
|
|
|
|
|
|
|
render() { |
|
|
render() { |
|
|
const { push, accounts, t, counterValue } = this.props |
|
|
const { push, accounts, t, counterValue } = this.props |
|
|
const { accountsChunk, selectedTime, daysCount } = this.state |
|
|
const { accountsChunk, selectedTime, daysCount } = this.state |
|
@ -109,9 +134,10 @@ class DashboardPage extends PureComponent<Props, State> { |
|
|
{totalAccounts > 0 && ( |
|
|
{totalAccounts > 0 && ( |
|
|
<Fragment> |
|
|
<Fragment> |
|
|
<BalanceSummary |
|
|
<BalanceSummary |
|
|
|
|
|
onCalculate={this.handleCalculateBalance} |
|
|
counterValue={counterValue} |
|
|
counterValue={counterValue} |
|
|
chartId="dashboard-chart" |
|
|
chartId="dashboard-chart" |
|
|
chartColor="#5286f7" |
|
|
chartColor={colors.wallet} |
|
|
accounts={accounts} |
|
|
accounts={accounts} |
|
|
selectedTime={selectedTime} |
|
|
selectedTime={selectedTime} |
|
|
daysCount={daysCount} |
|
|
daysCount={daysCount} |
|
|