fix: revalidate transactions when changing account (#165)

This commit is contained in:
Victor Oliva
2026-06-30 10:57:54 +02:00
committed by GitHub
parent 4032c4273b
commit 43fd7151a8

View File

@@ -15,7 +15,15 @@ import {
import { switchMapSuspended } from "@react-rxjs/utils"
import { CheckCircle, CircleX, Loader2 } from "lucide-react"
import { FC, ReactNode } from "react"
import { catchError, combineLatest, map, of, switchMap, timer } from "rxjs"
import {
catchError,
combineLatest,
map,
of,
startWith,
switchMap,
timer,
} from "rxjs"
import { transaction$, txOptions$ } from "./submit.state"
import { validate$ } from "./validate"
@@ -72,7 +80,13 @@ export const txValidity$ = state(
txOptions: txOptions$,
}).pipe(
switchMapSuspended(({ tx, txOptions }) =>
tx ? timer(500).pipe(switchMap(() => validate$(tx, txOptions))) : [null],
tx
? timer(500).pipe(
// Revalidate every time selectedAccount changes, with no delay
switchMap(() => selectedAccount$),
switchMap(() => validate$(tx, txOptions).pipe(startWith(null))),
)
: [null],
),
liftSuspense(),
map((v) => (v === SUSPENSE ? null : v)),