File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 12
12
"url" : " https://github.com/txnlab/use-wallet/issues"
13
13
},
14
14
"homepage" : " https://txnlab.github.io/use-wallet" ,
15
- "version" : " 1.2.3 " ,
15
+ "version" : " 1.2.4 " ,
16
16
"description" : " React hooks for using Algorand compatible wallets in dApps." ,
17
17
"scripts" : {
18
18
"dev" : " yarn storybook" ,
Original file line number Diff line number Diff line change
1
+ import { PROVIDER_ID } from "src/constants" ;
2
+ import { useWalletStore } from "src/store" ;
3
+
4
+ export const getActiveProviders = ( ) => {
5
+ const accounts = useWalletStore . getState ( ) . accounts ;
6
+ return [ ...new Set ( accounts . map ( ( acct ) => acct . providerId ) ) ] ;
7
+ }
8
+
9
+ export const isActiveProvider = ( id : PROVIDER_ID ) => {
10
+ const activeProviders = getActiveProviders ( ) ;
11
+ return activeProviders . includes ( id ) ;
12
+ }
Original file line number Diff line number Diff line change 1
1
import { WalletClient } from "../types" ;
2
2
import { clearAccounts } from "./clearAccounts" ;
3
+ import { isActiveProvider } from "./providers" ;
3
4
4
5
type SupportedProviders = { [ x : string ] : Promise < WalletClient | null > } ;
5
6
@@ -9,7 +10,12 @@ export const reconnectProviders = async (providers: SupportedProviders) => {
9
10
10
11
for ( const client of clients ) {
11
12
const c = await client ;
12
- c ?. reconnect ( ( ) => clearAccounts ( c ?. metadata . id ) ) ;
13
+ const id = c ?. metadata . id ;
14
+
15
+ // Only reconnect to active providers
16
+ if ( id && isActiveProvider ( id ) ) {
17
+ c . reconnect ( ( ) => clearAccounts ( id ) ) ;
18
+ }
13
19
}
14
20
} catch ( e ) {
15
21
console . error ( e ) ;
You can’t perform that action at this time.
0 commit comments