@@ -98,6 +98,9 @@ export const SwapConfirmationScene: React.FC<Props> = (props: Props) => {
9898
9999 const isFocused = useIsFocused ( )
100100
101+ const termsCheckPending = React . useRef ( false )
102+ const timerExpiredDuringTerms = React . useRef ( false )
103+
101104 const pickBestQuoteWithPreference = (
102105 allQuotes : EdgeSwapQuote [ ]
103106 ) : EdgeSwapQuote => {
@@ -206,6 +209,10 @@ export const SwapConfirmationScene: React.FC<Props> = (props: Props) => {
206209
207210 const handleExchangeTimerExpired = useHandler ( ( ) => {
208211 if ( ! isFocused ) return
212+ if ( termsCheckPending . current ) {
213+ timerExpiredDuringTerms . current = true
214+ return
215+ }
209216
210217 navigation . replace ( 'swapProcessing' , {
211218 swapRequest : selectedQuote . request ,
@@ -227,12 +234,20 @@ export const SwapConfirmationScene: React.FC<Props> = (props: Props) => {
227234 const swapConfig = account . swapConfig [ pluginId ]
228235
229236 dispatch ( logEvent ( 'Exchange_Shift_Quote' ) )
237+ termsCheckPending . current = true
230238 swapVerifyTerms ( swapConfig )
231239 . then ( async result => {
232- if ( ! result ) handleExchangeTimerExpired ( )
240+ termsCheckPending . current = false
241+ if ( ! result || timerExpiredDuringTerms . current ) {
242+ handleExchangeTimerExpired ( )
243+ }
233244 } )
234245 . catch ( ( err : unknown ) => {
246+ termsCheckPending . current = false
235247 showError ( err )
248+ if ( timerExpiredDuringTerms . current ) {
249+ handleExchangeTimerExpired ( )
250+ }
236251 } )
237252 } )
238253
0 commit comments