@@ -19,6 +19,7 @@ import {
19
19
SystemScript as SystemScriptSubject ,
20
20
DataUpdate as DataUpdateSubject ,
21
21
NetworkList as NetworkListSubject ,
22
+ CurrentNetworkID as CurrentNetworkIDSubject ,
22
23
} from 'services/subjects'
23
24
import { ckbCore , getTipBlockNumber , getBlockchainInfo } from 'services/chain'
24
25
import { Routes , Channel , ConnectionStatus } from 'utils/const'
@@ -266,14 +267,6 @@ export const useChannelListeners = ({
266
267
UILayer . on ( Channel . Networks , ( _e : Event , method : NetworksMethod , args : ChannelResponse < any > ) => {
267
268
if ( args . status ) {
268
269
switch ( method ) {
269
- case NetworksMethod . CurrentID : {
270
- dispatch ( {
271
- type : NeuronWalletActions . Chain ,
272
- payload : { networkID : args . result } ,
273
- } )
274
- currentNetworkIDCache . save ( args . result )
275
- break
276
- }
277
270
case NetworksMethod . Create :
278
271
case NetworksMethod . Update : {
279
272
history . push ( Routes . SettingsNetworks )
@@ -458,10 +451,18 @@ export const useSubscription = ({
458
451
} )
459
452
networksCache . save ( currentNetworkList )
460
453
} )
454
+ const currentNetworkIDSubscription = CurrentNetworkIDSubject . subscribe ( ( { currentNetworkID = '' } ) => {
455
+ dispatch ( {
456
+ type : NeuronWalletActions . UpdateCurrentNetworkID ,
457
+ payload : currentNetworkID ,
458
+ } )
459
+ currentNetworkIDCache . save ( currentNetworkID )
460
+ } )
461
461
return ( ) => {
462
462
systemScriptSubscription . unsubscribe ( )
463
463
dataUpdateSubscription . unsubscribe ( )
464
464
networkListSubscription . unsubscribe ( )
465
+ currentNetworkIDSubscription . unsubscribe ( )
465
466
}
466
467
} , [ walletID , pageNo , pageSize , keywords , txHash , dispatch ] )
467
468
}
0 commit comments