Skip to content

Commit

Permalink
Merge pull request #1967 from oasisprotocol/lw/fix-transactions-list
Browse files Browse the repository at this point in the history
Quick fix for updating transactions list by adding more delay
  • Loading branch information
lukaw3d authored Jun 4, 2024
2 parents 2864790 + 3d5856b commit cd27b32
Show file tree
Hide file tree
Showing 3 changed files with 6 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
2 changes: 2 additions & 0 deletions playwright/tests/refreshing-balance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ test('Account selector should refresh balances on network change', async ({ page
})

test('Accounts page should continuously refresh balance', async ({ page }) => {
test.setTimeout(120_000)
await page.getByTestId('account-selector').click()
await expect(page.getByTestId('account-balance-summary')).toContainText('123.0')
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 cd27b32

Please sign in to comment.