1
+ import { createMiddlewareWithExtraDeps } from '@suite-common/redux-utils' ;
2
+ import { periodicCheckTokenDefinitionsThunk } from '@suite-common/token-definitions' ;
1
3
import {
2
4
deviceActions ,
3
5
discoveryActions ,
@@ -6,14 +8,15 @@ import {
6
8
authorizeDeviceThunk ,
7
9
accountsActions ,
8
10
} from '@suite-common/wallet-core' ;
9
- import { createMiddlewareWithExtraDeps } from '@suite-common/redux-utils' ;
10
11
import { isFirmwareVersionSupported } from '@suite-native/device' ;
11
12
12
13
import { startDescriptorPreloadedDiscoveryThunk , discoveryCheckThunk } from './discoveryThunks' ;
13
14
import {
14
15
selectAreTestnetsEnabled ,
15
16
selectIsCoinEnablingInitFinished ,
16
17
toggleAreTestnetsEnabled ,
18
+ setEnabledDiscoveryNetworkSymbols ,
19
+ toggleEnabledDiscoveryNetworkSymbol ,
17
20
} from './discoveryConfigSlice' ;
18
21
19
22
export const prepareDiscoveryMiddleware = createMiddlewareWithExtraDeps (
@@ -75,6 +78,15 @@ export const prepareDiscoveryMiddleware = createMiddlewareWithExtraDeps(
75
78
dispatch ( discoveryCheckThunk ( ) ) ;
76
79
}
77
80
81
+ // if we changed enabled networks, check for token definitions right away
82
+ if (
83
+ ( toggleEnabledDiscoveryNetworkSymbol . match ( action ) ||
84
+ setEnabledDiscoveryNetworkSymbols . match ( action ) ) &&
85
+ isCoinEnablingInitFinished
86
+ ) {
87
+ dispatch ( periodicCheckTokenDefinitionsThunk ( ) ) ;
88
+ }
89
+
78
90
return action ;
79
91
} ,
80
92
) ;
0 commit comments