|
|
@ -73,6 +73,9 @@ const generateFakeData = v => ({ |
|
|
|
value: random(10, 100), |
|
|
|
}) |
|
|
|
|
|
|
|
const generateFakeDatas = accounts => |
|
|
|
accounts.map(() => [...Array(25).keys()].map(v => generateFakeData(v + 1))) |
|
|
|
|
|
|
|
const getAllTransactions = accounts => { |
|
|
|
const allTransactions = accounts.reduce((result, account) => { |
|
|
|
const transactions = get(account, 'data.transactions', []) |
|
|
@ -98,13 +101,24 @@ const getAllTransactions = accounts => { |
|
|
|
class DashboardPage extends PureComponent<Props, State> { |
|
|
|
state = { |
|
|
|
selectedTime: 'day', |
|
|
|
fakeDatas: this.generateFakeDatas(), |
|
|
|
fakeDatas: generateFakeDatas(this.props.accounts), |
|
|
|
} |
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
this.addFakeDatasOnAccounts() |
|
|
|
} |
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) { |
|
|
|
if ( |
|
|
|
this.state.fakeDatas.length === 0 && |
|
|
|
nextProps.accounts.length !== this.props.accounts.length |
|
|
|
) { |
|
|
|
this.setState({ |
|
|
|
fakeDatas: generateFakeDatas(nextProps.accounts), |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
componentWillUnmount() { |
|
|
|
clearTimeout(this._timeout) |
|
|
|
} |
|
|
@ -126,15 +140,11 @@ class DashboardPage extends PureComponent<Props, State> { |
|
|
|
saveSettings({ orderAccounts: order }) |
|
|
|
} |
|
|
|
|
|
|
|
generateFakeDatas() { |
|
|
|
const { accounts } = this.props |
|
|
|
return accounts.map(() => [...Array(25).keys()].map(v => generateFakeData(v + 1))) |
|
|
|
} |
|
|
|
|
|
|
|
addFakeDatasOnAccounts = () => { |
|
|
|
this._timeout = setTimeout(() => { |
|
|
|
const { accounts } = this.props |
|
|
|
|
|
|
|
this._timeout = setTimeout(() => { |
|
|
|
window.requestAnimationFrame(() => { |
|
|
|
this.setState(prev => ({ |
|
|
|
fakeDatas: [ |
|
|
|
...accounts.reduce((res, acc, i) => { |
|
|
@ -146,9 +156,8 @@ class DashboardPage extends PureComponent<Props, State> { |
|
|
|
}, prev.fakeDatas), |
|
|
|
], |
|
|
|
})) |
|
|
|
|
|
|
|
this.addFakeDatasOnAccounts() |
|
|
|
}, TIMEOUT_REFRESH_DATAS) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
_timeout = undefined |
|
|
|