|
| 1 | +import { random } from 'lodash-es' |
1 | 2 | import store from './store' |
2 | 3 |
|
3 | 4 | let balanceInterval |
4 | | -const BALANCE_UPDATE_INTERVAL = 30000 |
| 5 | +let fiatRatesInterval |
5 | 6 |
|
6 | 7 | store.subscribe(({ type, payload }, state) => { |
7 | 8 | switch (type) { |
8 | 9 | case 'CHANGE_ACTIVE_NETWORK': |
9 | 10 | store.dispatch('updateBalances', { network: state.activeNetwork, walletId: state.activeWalletId }) |
10 | 11 | store.dispatch('updateMarketData', { network: state.activeNetwork }) |
11 | | - |
12 | 12 | break |
13 | 13 |
|
14 | 14 | case 'UNLOCK_WALLET': |
15 | 15 | store.dispatch('updateBalances', { network: state.activeNetwork, walletId: state.activeWalletId }) |
| 16 | + store.dispatch('updateFiatRates') |
16 | 17 | store.dispatch('updateMarketData', { network: state.activeNetwork }) |
17 | 18 | store.dispatch('checkPendingSwaps', { walletId: state.activeWalletId }) |
18 | 19 |
|
19 | 20 | if (!balanceInterval) { |
20 | 21 | balanceInterval = setInterval(() => { |
21 | 22 | store.dispatch('updateBalances', { network: state.activeNetwork, walletId: state.activeWalletId }) |
22 | | - }, BALANCE_UPDATE_INTERVAL) |
| 23 | + }, random(20000, 30000)) |
| 24 | + } |
| 25 | + |
| 26 | + if (!fiatRatesInterval) { |
| 27 | + fiatRatesInterval = setInterval(() => { |
| 28 | + store.dispatch('updateFiatRates') |
| 29 | + }, random(20000, 30000)) |
23 | 30 | } |
24 | 31 |
|
25 | 32 | break |
|
0 commit comments