1414 * limitations under the License.
1515 */
1616
17- import React , { useEffect , useRef , useState } from 'react' ;
17+ import React , { useCallback , useEffect , useRef , useState } from 'react' ;
1818import { useTranslation } from 'react-i18next' ;
1919import * as backendAPI from '../../../api/backend' ;
2020import { SimpleMarkup } from '../../../utils/markup' ;
@@ -45,10 +45,6 @@ export const AddAccount = () => {
4545
4646 const { t } = useTranslation ( ) ;
4747
48- useEffect ( ( ) => {
49- startProcess ( ) ;
50- } , [ ] ) ;
51-
5248 useEffect ( ( ) => {
5349 if ( step === 'choose-name' ) {
5450 inputRef . current ?. focus ( ) ;
@@ -59,7 +55,7 @@ export const AddAccount = () => {
5955 return supportedCoins . length === 1 ;
6056 } ;
6157
62- const startProcess = async ( ) => {
58+ const startProcess = useCallback ( async ( ) => {
6359 try {
6460 const coins = await backendAPI . getSupportedCoins ( ) ;
6561 const onlyOneCoinIsSupported = ( coins . length === 1 ) ;
@@ -73,7 +69,16 @@ export const AddAccount = () => {
7369 } catch ( err ) {
7470 console . error ( err ) ;
7571 }
76- } ;
72+ } , [ ] ) ;
73+
74+ useEffect ( ( ) => {
75+ startProcess ( ) ;
76+
77+ const unsubscribe = backendAPI . syncKeystores ( ( ) => {
78+ startProcess ( ) ;
79+ } ) ;
80+ return unsubscribe ;
81+ } , [ startProcess ] ) ;
7782
7883 const back = ( ) => {
7984 switch ( step ) {
@@ -122,6 +127,13 @@ export const AddAccount = () => {
122127 const renderContent = ( ) => {
123128 switch ( step ) {
124129 case 'select-coin' :
130+ if ( supportedCoins . length === 0 ) {
131+ return (
132+ < div className = "text-center" >
133+ { t ( 'connectKeystore.promptNoName' ) }
134+ </ div >
135+ ) ;
136+ }
125137 return (
126138 < CoinDropDown
127139 onChange = { coin => {
0 commit comments