@@ -15,7 +15,11 @@ import UILayer, {
1515 networksCall ,
1616} from 'services/UILayer'
1717import { 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'
1923import { ckbCore , getTipBlockNumber , getBlockchainInfo } from 'services/chain'
2024import { Routes , Channel , ConnectionStatus } from 'utils/const'
2125import {
@@ -262,14 +266,6 @@ export const useChannelListeners = ({
262266 UILayer . on ( Channel . Networks , ( _e : Event , method : NetworksMethod , args : ChannelResponse < any > ) => {
263267 if ( args . status ) {
264268 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- }
273269 case NetworksMethod . CurrentID : {
274270 dispatch ( {
275271 type : NeuronWalletActions . Chain ,
@@ -455,9 +451,17 @@ export const useSubscription = ({
455451 }
456452 }
457453 } )
454+ const networkListSubscription = NetworkListSubject . subscribe ( ( { currentNetworkList = [ ] } ) => {
455+ dispatch ( {
456+ type : NeuronWalletActions . UpdateNetworkList ,
457+ payload : currentNetworkList ,
458+ } )
459+ networksCache . save ( currentNetworkList )
460+ } )
458461 return ( ) => {
459462 systemScriptSubscription . unsubscribe ( )
460463 dataUpdateSubscription . unsubscribe ( )
464+ networkListSubscription . unsubscribe ( )
461465 }
462466 } , [ walletID , pageNo , pageSize , keywords , txHash , dispatch ] )
463467}
0 commit comments