@@ -15,7 +15,11 @@ import UILayer, {
15
15
networksCall ,
16
16
} from 'services/UILayer'
17
17
import { initWindow } from 'services/remote'
18
- import { SystemScript as SystemScriptSubject , DataUpdate as DataUpdateSubject } from 'services/subjects'
18
+ import {
19
+ SystemScript as SystemScriptSubject ,
20
+ DataUpdate as DataUpdateSubject ,
21
+ NetworkList as NetworkListSubject ,
22
+ } from 'services/subjects'
19
23
import { ckbCore , getTipBlockNumber , getBlockchainInfo } from 'services/chain'
20
24
import { Routes , Channel , ConnectionStatus } from 'utils/const'
21
25
import {
@@ -262,14 +266,6 @@ export const useChannelListeners = ({
262
266
UILayer . on ( Channel . Networks , ( _e : Event , method : NetworksMethod , args : ChannelResponse < any > ) => {
263
267
if ( args . status ) {
264
268
switch ( method ) {
265
- case NetworksMethod . GetAll : {
266
- dispatch ( {
267
- type : NeuronWalletActions . Settings ,
268
- payload : { networks : args . result || [ ] } ,
269
- } )
270
- networksCache . save ( args . result || [ ] )
271
- break
272
- }
273
269
case NetworksMethod . CurrentID : {
274
270
dispatch ( {
275
271
type : NeuronWalletActions . Chain ,
@@ -455,9 +451,17 @@ export const useSubscription = ({
455
451
}
456
452
}
457
453
} )
454
+ const networkListSubscription = NetworkListSubject . subscribe ( ( { currentNetworkList = [ ] } ) => {
455
+ dispatch ( {
456
+ type : NeuronWalletActions . UpdateNetworkList ,
457
+ payload : currentNetworkList ,
458
+ } )
459
+ networksCache . save ( currentNetworkList )
460
+ } )
458
461
return ( ) => {
459
462
systemScriptSubscription . unsubscribe ( )
460
463
dataUpdateSubscription . unsubscribe ( )
464
+ networkListSubscription . unsubscribe ( )
461
465
}
462
466
} , [ walletID , pageNo , pageSize , keywords , txHash , dispatch ] )
463
467
}
0 commit comments