Skip to content

Commit

Permalink
Fix updating transactions list by adding more delay
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Jun 4, 2024
1 parent 2864790 commit 088d53d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/1967.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix updating transactions list by adding more delay
1 change: 1 addition & 0 deletions playwright/tests/refreshing-balance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test('Accounts page should continuously refresh balance', async ({ page }) => {
await expect(page.getByTestId('account-choice')).toContainText('123.0')
await mockApi(page, 456)
await page.waitForRequest('**/chain/account/info/*', { timeout: 60_000 })
await page.waitForRequest('**/chain/transactions*', { timeout: 60_000 })
await expect(page.getByTestId('account-balance-summary')).toContainText('456.0')
await expect(page.getByTestId('account-choice')).toContainText('456.0')
// If balance in AccountSelector is not refreshed then making transactions with new balance will fail.
Expand Down
3 changes: 3 additions & 0 deletions src/app/state/account/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getAccountBalanceWithFallback } from '../../lib/getAccountBalanceWithFa
import { walletActions } from '../wallet'

const ACCOUNT_REFETCHING_INTERVAL = process.env.REACT_APP_E2E_TEST ? 5 * 1000 : 30 * 1000
const TRANSACTIONS_UPDATE_DELAY = 35 * 1000 // Measured between 8 and 31 second additional delay after balance updates
const TRANSACTIONS_LIMIT = 20

export function* fetchAccount(action: PayloadAction<string>) {
Expand Down Expand Up @@ -130,6 +131,8 @@ export function* fetchingOnAccountPage() {
staleBalances.delegations !== refreshedAccount.delegations ||
staleBalances.debonding !== refreshedAccount.debonding
) {
// Wait for oasisscan to update transactions (it updates balances faster)
yield* delay(TRANSACTIONS_UPDATE_DELAY)
yield* call(fetchAccount, startAction)
yield* call(stakingFetchAccount, startAction)
yield* call(walletRefreshAccount, address)
Expand Down

0 comments on commit 088d53d

Please sign in to comment.