diff --git a/.circleci/config.yml b/.circleci/config.yml index 7f64c5b7..7aa63879 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,8 +16,8 @@ jobs: name: Flow typed command: yarn flow-typed - run: - name: Temporary remove flow definitions for react-redux - command: rm flow-typed/npm/react-redux_v5.x.x.js + name: Temporary remove broken flow definitions + command: rm flow-typed/npm/{react-redux_v5.x.x.js,redux_v3.x.x.js} - run: name: Lint command: yarn lint diff --git a/package.json b/package.json index 7d0272e8..e9bdf975 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "bitcoinjs-lib": "^3.3.2", "bs58check": "^2.1.1", "color": "^3.0.0", - "cross-env": "^5.1.3", + "cross-env": "^5.1.4", "d3": "^4.13.0", "debug": "^3.1.0", "downshift": "^1.30.0", @@ -69,9 +69,9 @@ "moment": "^2.20.1", "object-path": "^0.11.4", "qrcode": "^1.2.0", - "query-string": "^5.1.0", + "query-string": "^6.0.0", "raven": "^2.4.2", - "raven-js": "^3.22.4", + "raven-js": "^3.23.2", "react": "^16.2.0", "react-dom": "^16.2.0", "react-i18next": "^7.5.0", @@ -89,9 +89,9 @@ "smooth-scrollbar": "^8.2.6", "source-map": "0.6.0", "source-map-support": "^0.5.3", - "styled-components": "^3.2.1", + "styled-components": "^3.2.2", "styled-system": "^2.2.1", - "tippy.js": "^2.2.3", + "tippy.js": "^2.3.0", "victory": "^0.25.6" }, "devDependencies": { @@ -114,7 +114,7 @@ "concurrently": "^3.5.1", "dotenv": "^5.0.1", "electron": "1.8.3", - "electron-builder": "^20.4.0", + "electron-builder": "^20.5.1", "electron-devtools-installer": "^2.2.3", "electron-rebuild": "^1.7.3", "electron-webpack": "1.13.0", diff --git a/src/actions/accounts.js b/src/actions/accounts.js index 9336d059..dd859e16 100644 --- a/src/actions/accounts.js +++ b/src/actions/accounts.js @@ -9,7 +9,7 @@ import type { Account } from 'types/common' import { fetchCounterValues } from 'actions/counterValues' -import { startSyncAccounts } from 'renderer/events' +import { startSyncAccounts, startSyncCounterValues } from 'renderer/events' function sortAccounts(accounts, orderAccounts) { const [order, sort] = orderAccounts.split('|') @@ -43,7 +43,7 @@ export const updateOrderAccounts: UpdateOrderAccounts = (orderAccounts: string) export type AddAccount = Account => (Function, Function) => void export const addAccount: AddAccount = payload => (dispatch, getState) => { - const { settings: { orderAccounts }, accounts } = getState() + const { settings: { counterValue, orderAccounts }, accounts } = getState() dispatch({ type: 'ADD_ACCOUNT', payload, @@ -52,7 +52,9 @@ export const addAccount: AddAccount = payload => (dispatch, getState) => { // Start sync accounts the first time you add an account if (accounts.length === 0) { - startSyncAccounts([payload]) + const accounts = [payload] + startSyncCounterValues(counterValue, accounts) + startSyncAccounts(accounts) } } diff --git a/src/actions/counterValues.js b/src/actions/counterValues.js index 8bb055f2..e5bc5e70 100644 --- a/src/actions/counterValues.js +++ b/src/actions/counterValues.js @@ -6,6 +6,8 @@ import { getDefaultUnitByCoinType } from '@ledgerhq/currencies' import type { Dispatch } from 'redux' +import { serializeCounterValues } from 'reducers/counterValues' + import get from 'lodash/get' import db from 'helpers/db' @@ -22,6 +24,15 @@ export const updateCounterValues: UpdateCounterValues = payload => ({ payload, }) +export type UpdateLastCounterValueBySymbol = (string, Object) => { type: string, payload: Object } +export const updateLastCounterValueBySymbol: UpdateLastCounterValueBySymbol = (symbol, value) => ({ + type: 'DB:UPDATE_LAST_COUNTER_VALUE', + payload: { + symbol, + value, + }, +}) + export type FetchCounterValues = (?number) => (Dispatch<*>, Function) => Promise export const fetchCounterValues: FetchCounterValues = coinType => (dispatch, getState) => { const { accounts, counterValues, settings } = getState() @@ -51,21 +62,19 @@ export const fetchCounterValues: FetchCounterValues = coinType => (dispatch, get ) .then(({ data }) => ({ symbol: `${code}-${counterValue}`, - values: data.Data.reduce((result, d) => { - const date = moment(d.time * 1000).format('YYYY-MM-DD') - result[date] = d.close - return result - }, {}), + values: data.Data.map(d => [moment(d.time * 1000).format('YYYY-MM-DD'), d.close]), })) } - return Promise.all(coinTypes.map(fetchCounterValuesByCoinType)).then(result => { - const newCounterValues = result.reduce((r, v) => { - if (v !== null) { - r[v.symbol] = v.values - } - return r - }, {}) + return Promise.all(coinTypes.map(fetchCounterValuesByCoinType)).then(results => { + const newCounterValues = serializeCounterValues( + results.reduce((r, v) => { + if (v !== null) { + r[v.symbol] = v.values + } + return r + }, {}), + ) if (Object.keys(newCounterValues).length !== 0) { dispatch(updateCounterValues(newCounterValues)) diff --git a/src/components/AccountPage/index.js b/src/components/AccountPage/index.js index 4375d8dd..73e97599 100644 --- a/src/components/AccountPage/index.js +++ b/src/components/AccountPage/index.js @@ -28,7 +28,7 @@ import Box from 'components/base/Box' import Button from 'components/base/Button' import FormattedVal from 'components/base/FormattedVal' import PillsDaysCount from 'components/PillsDaysCount' -import TransactionsList from 'components/TransactionsList' +import OperationsList from 'components/OperationsList' import AccountHeader from './AccountHeader' @@ -79,19 +79,20 @@ class AccountPage extends PureComponent { - -