|
@ -63,24 +63,30 @@ export function checkUpdates() { |
|
|
|
|
|
|
|
|
export default ({ store, locked }: { store: Object, locked: boolean }) => { |
|
|
export default ({ store, locked }: { store: Object, locked: boolean }) => { |
|
|
const handlers = { |
|
|
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: { |
|
|
accounts: { |
|
|
sync: { |
|
|
sync: { |
|
|
success: accounts => { |
|
|
success: () => { |
|
|
if (syncAccounts) { |
|
|
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(() => { |
|
|
syncTimeout = setTimeout(() => { |
|
|
const newAccounts = getAccounts(store.getState()) |
|
|
const accounts = getAccounts(store.getState()) |
|
|
startSyncAccounts(newAccounts) |
|
|
startSyncAccounts(accounts) |
|
|
}, SYNC_ACCOUNT_TIMEOUT) |
|
|
}, SYNC_ACCOUNT_TIMEOUT) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|