Skip to content

Commit

Permalink
Merge pull request #1963 from oasisprotocol/lw/debonding-refreshing
Browse files Browse the repository at this point in the history
Fix refreshing transactions after making a debonding transaction
  • Loading branch information
lukaw3d authored May 30, 2024
2 parents dcb01bf + 69b5d6d commit 246f2ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .changelog/1963.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix refreshing transactions after making a debonding transaction
13 changes: 9 additions & 4 deletions src/app/state/account/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fetchAccount as stakingFetchAccount } from '../staking/saga'
import { refreshAccount as walletRefreshAccount } from '../wallet/saga'
import { transactionActions } from '../transaction'
import { selectAddress } from '../wallet/selectors'
import { selectAccountAddress, selectAccountAvailableBalance } from './selectors'
import { selectAccountAddress, selectAccount } from './selectors'
import { getAccountBalanceWithFallback } from '../../lib/getAccountBalanceWithFallback'
import { walletActions } from '../wallet'

Expand Down Expand Up @@ -110,7 +110,7 @@ export function* fetchingOnAccountPage() {
yield* put(stakingActions.fetchAccount(address))
yield* take(accountActions.accountLoaded)

// Start refetching balance. If balance changes then fetch transactions and staking too.
// Continuously refresh balance. If balance changes then fetch transactions and staking too.
while (true) {
yield* delay(ACCOUNT_REFETCHING_INTERVAL)
if (document.hidden) continue
Expand All @@ -123,8 +123,13 @@ export function* fetchingOnAccountPage() {
console.error('refetching account failed, continuing without updated account.', apiError)
continue // Ignore error when refetching, and don't fallback to more expensive gRPC
}
const staleAvailableBalance = yield* select(selectAccountAvailableBalance)
if (staleAvailableBalance !== refreshedAccount.available) {

const staleBalances = yield* select(selectAccount)
if (
staleBalances.available !== refreshedAccount.available ||
staleBalances.delegations !== refreshedAccount.delegations ||
staleBalances.debonding !== refreshedAccount.debonding
) {
yield* call(fetchAccount, startAction)
yield* call(stakingFetchAccount, startAction)
yield* call(walletRefreshAccount, address)
Expand Down

0 comments on commit 246f2ce

Please sign in to comment.