diff --git a/package.json b/package.json index 855b467e..d38e4abe 100644 --- a/package.json +++ b/package.json @@ -40,17 +40,17 @@ "webpack-sources": "1.0.1" }, "dependencies": { - "@fortawesome/fontawesome": "^1.1.3", "@fortawesome/fontawesome-free-brands": "^5.0.6", "@fortawesome/fontawesome-free-regular": "^5.0.6", "@fortawesome/fontawesome-free-solid": "^5.0.6", + "@fortawesome/fontawesome": "^1.1.3", "@fortawesome/react-fontawesome": "^0.0.17", "@ledgerhq/common": "2.3.0", "@ledgerhq/currencies": "^2.3.0", "@ledgerhq/hw-app-btc": "^4.0.0", "@ledgerhq/hw-app-eth": "^4.0.0", - "@ledgerhq/hw-transport": "^4.0.0", "@ledgerhq/hw-transport-node-hid": "^4.0.0", + "@ledgerhq/hw-transport": "^4.0.0", "axios": "^0.17.1", "babel-runtime": "^6.26.0", "bcryptjs": "^2.4.3", @@ -58,35 +58,36 @@ "bs58check": "^2.1.1", "color": "^3.0.0", "cross-env": "^5.1.3", + "debug": "^3.1.0", "downshift": "^1.28.0", "electron-store": "^1.3.0", "electron-updater": "^2.20.1", "fuse.js": "^3.2.0", "history": "^4.7.2", - "i18next": "^10.2.2", "i18next-node-fs-backend": "^1.0.0", + "i18next": "^10.2.2", "lodash": "^4.17.5", "moment": "^2.20.1", "object-path": "^0.11.4", "qrcode": "^1.2.0", "query-string": "^5.1.0", - "raven": "^2.4.1", "raven-js": "^3.22.3", - "react": "^16.2.0", + "raven": "^2.4.1", "react-dom": "^16.2.0", "react-i18next": "^7.3.6", "react-mortal": "^3.2.0", "react-motion": "^0.5.2", "react-qr-reader": "^2.0.1", "react-redux": "^5.0.6", - "react-router": "^4.2.0", "react-router-dom": "^4.2.2", "react-router-redux": "5.0.0-alpha.9", + "react-router": "^4.2.0", "react-smooth-scrollbar": "^8.0.6", + "react": "^16.2.0", "recharts": "^1.0.0-beta.10", - "redux": "^3.7.2", "redux-actions": "^2.2.1", "redux-thunk": "^2.2.0", + "redux": "^3.7.2", "smooth-scrollbar": "^8.2.6", "source-map-support": "^0.5.3", "styled-components": "^3.1.6", diff --git a/scripts/start.sh b/scripts/start.sh index 1302e516..f9016a41 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -2,4 +2,4 @@ concurrently --raw \ "cross-env NODE_ENV=development webpack --watch --config webpack/internals.config.js" \ - "cross-env NODE_ENV=development electron-webpack dev" + "cross-env DEBUG=lwd* NODE_ENV=development electron-webpack dev" diff --git a/src/components/DevToolbar.js b/src/components/DevTools.js similarity index 91% rename from src/components/DevToolbar.js rename to src/components/DevTools.js index 1e3ba583..719f1d81 100644 --- a/src/components/DevToolbar.js +++ b/src/components/DevTools.js @@ -116,7 +116,7 @@ type State = { cpuUsage: Object, } -class DevToolbar extends PureComponent { +class DevTools extends PureComponent { state = { cpuUsage: {}, } @@ -155,20 +155,22 @@ class DevToolbar extends PureComponent { }) } + handleStartSync = () => + mainWindow.webContents.send('msg', { + type: 'accounts.sync.start', + }) + + handleStopSync = () => + mainWindow.webContents.send('msg', { + type: 'accounts.sync.stop', + }) + render() { const { cpuUsage } = this.state return ( -
- {languages.map(lang => ( - - {lang} - - ))} -
-
{chunk(colors, 5).map((c, i) => ( { ))}
+
+ {languages.map(lang => ( + + {lang} + + ))} +
+ +
+ + Start + + + Stop + +
+
{chunk(Object.keys(cpuUsage).sort(), 2).map((l, i) => ( { return ( - + ) diff --git a/src/renderer/events.js b/src/renderer/events.js index fb695bf4..04172842 100644 --- a/src/renderer/events.js +++ b/src/renderer/events.js @@ -4,6 +4,7 @@ import { ipcRenderer } from 'electron' import objectPath from 'object-path' import get from 'lodash/get' import uniqBy from 'lodash/uniqBy' +import debug from 'debug' import type { Accounts } from 'types/common' @@ -12,10 +13,17 @@ import { CHECK_UPDATE_TIMEOUT, SYNC_ACCOUNT_TIMEOUT } from 'constants' import { updateDevices, addDevice, removeDevice } from 'actions/devices' import { updateAccount } from 'actions/accounts' import { setUpdateStatus } from 'reducers/update' -import { getAccountData, getAccounts } from 'reducers/accounts' +import { getAccountData, getAccounts, getAccountById } from 'reducers/accounts' +import { isLocked } from 'reducers/application' import i18n from 'renderer/i18n' +const d = { + device: debug('lwd:device'), + sync: debug('lwd:sync'), + update: debug('lwd:update'), +} + const { DISABLED_SYNC, DISABLED_AUTO_SYNC } = process.env type MsgPayload = { @@ -41,6 +49,7 @@ export function sendSyncEvent(channel: string, msgType: string, data: any): any } export function startSyncAccounts(accounts: Accounts) { + d.sync('Sync accounts - start') syncAccounts = true sendEvent('accounts', 'sync.all', { accounts: accounts.map(account => { @@ -56,11 +65,13 @@ export function startSyncAccounts(accounts: Accounts) { } export function stopSyncAccounts() { + d.sync('Sync accounts - stop') syncAccounts = false clearTimeout(syncTimeout) } export function checkUpdates() { + d.update('Update - check') setTimeout(() => sendEvent('msg', 'updater.init'), CHECK_UPDATE_TIMEOUT) } @@ -74,7 +85,9 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => { sync: { success: account => { if (syncAccounts) { - const currentAccountData = getAccountData(store.getState(), account.id) || {} + const state = store.getState() + const currentAccount = getAccountById(state, account.id) || {} + const currentAccountData = getAccountData(state, account.id) || {} const currentAccountTransactions = get(currentAccountData, 'transactions', []) const transactions = uniqBy( @@ -83,6 +96,7 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => { ) if (currentAccountTransactions.length !== transactions.length) { + d.sync(`Update account - ${currentAccount.name}`) store.dispatch( updateAccount({ ...account, @@ -99,8 +113,21 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => { }, accounts: { sync: { + start: () => { + if (!syncAccounts) { + const state = store.getState() + const accounts = getAccounts(state) + const locked = isLocked(state) + + if (!locked && !DISABLED_SYNC) { + startSyncAccounts(accounts) + } + } + }, + stop: stopSyncAccounts, success: () => { if (syncAccounts && !DISABLED_AUTO_SYNC) { + d.sync('Sync accounts - success') syncTimeout = setTimeout(() => { const accounts = getAccounts(store.getState()) startSyncAccounts(accounts) @@ -115,8 +142,14 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => { }, }, device: { - add: device => store.dispatch(addDevice(device)), - remove: device => store.dispatch(removeDevice(device)), + add: device => { + d.device('Device - add') + store.dispatch(addDevice(device)) + }, + remove: device => { + d.device('Device - remove') + store.dispatch(removeDevice(device)) + }, }, updater: { checking: () => store.dispatch(setUpdateStatus('checking')),