@@ -377,8 +377,12 @@ export class AppKit extends AppKitScaffold {
377
377
} ) ;
378
378
379
379
watchAccount ( wagmiConfig , {
380
- onChange : accountData => {
380
+ onChange : ( accountData , prevAccountData ) => {
381
381
this . syncAccount ( { ...accountData } ) ;
382
+
383
+ if ( accountData . status === 'disconnected' && prevAccountData . status === 'connected' ) {
384
+ this . close ( ) ;
385
+ }
382
386
}
383
387
} ) ;
384
388
}
@@ -431,7 +435,7 @@ export class AppKit extends AppKitScaffold {
431
435
'address' | 'isConnected' | 'chainId' | 'connector' | 'isConnecting' | 'isReconnecting'
432
436
> ) {
433
437
this . syncNetwork ( address , chainId , isConnected ) ;
434
- this . setLoading ( isConnecting || isReconnecting ) ;
438
+ this . setLoading ( ! ! connector && ( isConnecting || isReconnecting ) ) ;
435
439
436
440
if ( isConnected && address && chainId ) {
437
441
const caipAddress : CaipAddress = `${ ConstantsUtil . EIP155 } :${ chainId } :${ address } ` ;
@@ -444,8 +448,7 @@ export class AppKit extends AppKitScaffold {
444
448
this . getApprovedCaipNetworksData ( )
445
449
] ) ;
446
450
this . hasSyncedConnectedAccount = true ;
447
- } else if ( ! isConnected && this . hasSyncedConnectedAccount ) {
448
- this . close ( ) ;
451
+ } else if ( ! isConnected && ! isConnecting && ! isReconnecting && this . hasSyncedConnectedAccount ) {
449
452
this . resetAccount ( ) ;
450
453
this . resetWcConnection ( ) ;
451
454
this . resetNetwork ( ) ;
@@ -619,7 +622,6 @@ export class AppKit extends AppKitScaffold {
619
622
620
623
provider . onSetPreferredAccount ( async ( ) => {
621
624
await reconnect ( this . wagmiConfig , { connectors : [ connector ] } ) ;
622
- this . setLoading ( false ) ;
623
625
} ) ;
624
626
625
627
provider . setOnTimeout ( async ( ) => {
0 commit comments