@@ -19,6 +19,7 @@ import {
1919 SystemScript as SystemScriptSubject ,
2020 DataUpdate as DataUpdateSubject ,
2121 NetworkList as NetworkListSubject ,
22+ CurrentNetworkID as CurrentNetworkIDSubject ,
2223} from 'services/subjects'
2324import { ckbCore , getTipBlockNumber , getBlockchainInfo } from 'services/chain'
2425import { Routes , Channel , ConnectionStatus } from 'utils/const'
@@ -266,14 +267,6 @@ export const useChannelListeners = ({
266267 UILayer . on ( Channel . Networks , ( _e : Event , method : NetworksMethod , args : ChannelResponse < any > ) => {
267268 if ( args . status ) {
268269 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- }
277270 case NetworksMethod . Create :
278271 case NetworksMethod . Update : {
279272 history . push ( Routes . SettingsNetworks )
@@ -458,10 +451,18 @@ export const useSubscription = ({
458451 } )
459452 networksCache . save ( currentNetworkList )
460453 } )
454+ const currentNetworkIDSubscription = CurrentNetworkIDSubject . subscribe ( ( { currentNetworkID = '' } ) => {
455+ dispatch ( {
456+ type : NeuronWalletActions . UpdateCurrentNetworkID ,
457+ payload : currentNetworkID ,
458+ } )
459+ currentNetworkIDCache . save ( currentNetworkID )
460+ } )
461461 return ( ) => {
462462 systemScriptSubscription . unsubscribe ( )
463463 dataUpdateSubscription . unsubscribe ( )
464464 networkListSubscription . unsubscribe ( )
465+ currentNetworkIDSubscription . unsubscribe ( )
465466 }
466467 } , [ walletID , pageNo , pageSize , keywords , txHash , dispatch ] )
467468}
0 commit comments