Browse Source
Sync each account one by one instead of all accounts
master
Loëck Vézien
7 years ago
No known key found for this signature in database
GPG Key ID: CBCDCE384E853AC4
2 changed files with
26 additions and
16 deletions
-
src/internals/accounts/sync.js
-
src/renderer/events.js
|
|
@ -17,9 +17,13 @@ export default (send: Function) => ({ |
|
|
|
send('accounts.sync.progress', null, { kill: false }) |
|
|
|
|
|
|
|
try { |
|
|
|
const result = await Promise.all(accounts.map(syncAccount)) |
|
|
|
await Promise.all( |
|
|
|
accounts.map(a => |
|
|
|
syncAccount(a).then(account => send('account.sync.success', account, { kill: false })), |
|
|
|
), |
|
|
|
) |
|
|
|
|
|
|
|
send('accounts.sync.success', result) |
|
|
|
send('accounts.sync.success') |
|
|
|
} catch (err) { |
|
|
|
send('accounts.sync.fail', err.stack || err) |
|
|
|
} |
|
|
|
|
|
@ -63,24 +63,30 @@ export function checkUpdates() { |
|
|
|
|
|
|
|
export default ({ store, locked }: { store: Object, locked: boolean }) => { |
|
|
|
const handlers = { |
|
|
|
account: { |
|
|
|
sync: { |
|
|
|
success: account => { |
|
|
|
if (syncAccounts) { |
|
|
|
const currentAccountData = getAccountData(store.getState(), account.id) || {} |
|
|
|
const transactions = uniqBy( |
|
|
|
[...currentAccountData.transactions, ...account.transactions], |
|
|
|
tx => tx.hash, |
|
|
|
) |
|
|
|
|
|
|
|
if (currentAccountData.transactions.length !== transactions.length) { |
|
|
|
store.dispatch(syncAccount(account)) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
accounts: { |
|
|
|
sync: { |
|
|
|
success: accounts => { |
|
|
|
success: () => { |
|
|
|
if (syncAccounts) { |
|
|
|
const currentState = store.getState() |
|
|
|
accounts.forEach(account => { |
|
|
|
const currentAccountData = getAccountData(currentState, account.id) || {} |
|
|
|
const transactions = uniqBy( |
|
|
|
[...currentAccountData.transactions, ...account.transactions], |
|
|
|
tx => tx.hash, |
|
|
|
) |
|
|
|
if (currentAccountData.transactions.length !== transactions.length) { |
|
|
|
store.dispatch(syncAccount(account)) |
|
|
|
} |
|
|
|
}) |
|
|
|
syncTimeout = setTimeout(() => { |
|
|
|
const newAccounts = getAccounts(store.getState()) |
|
|
|
startSyncAccounts(newAccounts) |
|
|
|
const accounts = getAccounts(store.getState()) |
|
|
|
startSyncAccounts(accounts) |
|
|
|
}, SYNC_ACCOUNT_TIMEOUT) |
|
|
|
} |
|
|
|
}, |
|
|
|