Browse Source

Clean stuff

master
Loëck Vézien 7 years ago
parent
commit
6301346936
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 2
      src/components/AccountPage.js
  2. 1
      src/components/AppRegionDrag.js
  3. 2
      src/components/base/Modal/index.js
  4. 2
      src/components/modals/AddAccount.js
  5. 11
      src/reducers/accounts.js
  6. 11
      src/renderer/events.js

2
src/components/AccountPage.js

@ -43,7 +43,7 @@ class AccountPage extends PureComponent<Props> {
</Box>
</Box>
<Card title="Last operations">
{accountData.transactions.map(tr => (
{accountData.transactions.reverse().map(tr => (
<Box horizontal key={tr.hash}>
<Box grow>{'-'}</Box>
<Box>{format(tr.balance)}</Box>

1
src/components/AppRegionDrag.js

@ -6,4 +6,5 @@ export default styled.div`
-webkit-app-region: drag;
background: ${p => p.theme.colors.white};
height: 40px;
z-index: 21;
`

2
src/components/base/Modal/index.js

@ -51,7 +51,7 @@ const Container = styled(Box).attrs({
})`
overflow: hidden;
position: fixed;
z-index: 1;
z-index: 20;
`
const Backdrop = styled(Box).attrs({

2
src/components/modals/AddAccount.js

@ -133,7 +133,7 @@ class AddAccountModal extends PureComponent<Props, State> {
componentWillReceiveProps(nextProps) {
const { currentDevice } = nextProps
if (this.state.step !== 'createAccount') {
if (this.props.currentDevice === null && this.state.step !== 'createAccount') {
this.setState({
step: currentDevice !== null ? 'startWallet' : 'connectDevice',
})

11
src/reducers/accounts.js

@ -24,15 +24,14 @@ const handlers: Object = {
{ payload: { accountID, data } }: { payload: { accountID: string, data: AccountData } },
): AccountsState => {
const account = state[accountID]
const { data: accountData } = account
const balance = get(account.data, 'balance', 0)
const transactions = get(account.data, 'transactions', [])
const currentIndex = data.currentIndex
? data.currentIndex
: get(account.data, 'currentIndex', 0)
const balance = get(accountData, 'balance', 0)
const transactions = get(accountData, 'transactions', [])
const currentIndex = data.currentIndex ? data.currentIndex : get(accountData, 'currentIndex', 0)
account.data = {
...account.data,
...accountData,
...data,
balance: balance + data.balance,
currentIndex,

11
src/renderer/events.js

@ -6,6 +6,7 @@ import objectPath from 'object-path'
import { updateDevices, addDevice, removeDevice } from 'actions/devices'
import { syncAccount } from 'actions/accounts'
import { setUpdateStatus } from 'reducers/update'
import { getAccounts } from 'reducers/accounts'
type MsgPayload = {
type: string,
@ -30,7 +31,9 @@ export function sendSyncEvent(channel: string, msgType: string, data: any): any
})
}
function syncAccounts(accounts) {
function startSyncAccounts(store) {
const accounts = getAccounts(store.getState())
sendEvent('accounts', 'sync.all', {
accounts: Object.entries(accounts).map(([id, account]: [string, any]) => ({
id,
@ -45,7 +48,7 @@ export default (store: Object) => {
sync: {
success: accounts => {
accounts.forEach(account => store.dispatch(syncAccount(account)))
setTimeout(() => syncAccounts(store.getState().accounts), SYNC_ACCOUNT_TIMEOUT)
setTimeout(() => startSyncAccounts(store), SYNC_ACCOUNT_TIMEOUT)
},
},
},
@ -77,8 +80,6 @@ export default (store: Object) => {
handler(data)
})
const state = store.getState()
// First time, we get all devices
sendEvent('usb', 'devices.all')
@ -86,7 +87,7 @@ export default (store: Object) => {
sendEvent('usb', 'devices.listen')
// Start accounts sync
syncAccounts(state.accounts)
startSyncAccounts(store)
if (__PROD__) {
// Start check of eventual updates

Loading…
Cancel
Save