@@ -24,17 +24,21 @@ import { Header } from '../../components/layout';
2424import { BlockExplorers } from './block-explorers' ;
2525import * as backendAPI from '../../api/backend' ;
2626import { getConfig , setConfig } from '../../utils/config' ;
27- import { CoinCode } from '../../api/account' ;
27+ import { CoinCode , IAccount } from '../../api/account' ;
2828import { MobileHeader } from './components/mobile-header' ;
2929import { useCallback , useEffect , useRef , useState } from 'react' ;
3030
31- export const SelectExplorerSettings = ( ) => {
31+ type TSelectExplorerSettingsProps = {
32+ accounts : IAccount [ ] ;
33+ }
34+
35+ export const SelectExplorerSettings = ( { accounts } : TSelectExplorerSettingsProps ) => {
3236 const { t } = useTranslation ( ) ;
3337
3438 const initialConfig = useRef < any > ( ) ;
3539 const [ config , setConfigState ] = useState < any > ( ) ;
3640
37- const [ supportedCoins , setSupportedCoins ] = useState < backendAPI . ICoin [ ] > ( [ ] ) ;
41+ const availableCoins = new Set ( accounts . map ( account => account . coinCode ) ) ;
3842 const [ allSelections , setAllSelections ] = useState < backendAPI . TAvailableExplorers > ( ) ;
3943
4044 const [ saveDisabled , setSaveDisabled ] = useState ( true ) ;
@@ -68,13 +72,11 @@ export const SelectExplorerSettings = () => {
6872
6973 useEffect ( ( ) => {
7074 const fetchData = async ( ) => {
71- const coins = await backendAPI . getSupportedCoins ( ) ;
7275 const allExplorerSelection = await backendAPI . getAvailableExplorers ( ) ;
7376
7477 // if set alongside config it will 'update' with it, but we want it to stay the same after initialization.
7578 initialConfig . current = await getConfig ( ) ;
7679
77- setSupportedCoins ( coins ) ;
7880 setAllSelections ( allExplorerSelection ) ;
7981 } ;
8082
@@ -99,14 +101,14 @@ export const SelectExplorerSettings = () => {
99101 </ >
100102 } />
101103 < div className = "content padded" >
102- { supportedCoins . map ( coin => {
104+ { Array . from ( availableCoins ) . map ( coin => {
103105 return < BlockExplorers
104- key = { coin . coinCode }
105- coin = { coin . coinCode }
106- explorerOptions = { allSelections ?. [ coin . coinCode ] ?? [ ] }
106+ key = { coin }
107+ coin = { coin }
108+ explorerOptions = { allSelections ?. [ coin ] ?? [ ] }
107109 handleOnChange = { handleChange }
108- selectedPrefix = { config . backend . blockExplorers ?. [ coin . coinCode ] } /> ;
109- } ) }
110+ selectedPrefix = { config . backend . blockExplorers ?. [ coin ] } /> ;
111+ } ) }
110112 </ div >
111113 < div className = "content padded" style = { { display : 'flex' , justifyContent : 'space-between' } } >
112114 < ButtonLink
0 commit comments