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' ;
20+ import * as keystoresAPI from '../../../api/keystores' ;
2021import { SimpleMarkup } from '../../../utils/markup' ;
2122import { Message } from '../../../components/message/message' ;
2223import { Button , Input } from '../../../components/forms' ;
@@ -45,10 +46,6 @@ export const AddAccount = () => {
4546
4647 const { t } = useTranslation ( ) ;
4748
48- useEffect ( ( ) => {
49- startProcess ( ) ;
50- } , [ ] ) ;
51-
5249 useEffect ( ( ) => {
5350 if ( step === 'choose-name' ) {
5451 inputRef . current ?. focus ( ) ;
@@ -59,7 +56,7 @@ export const AddAccount = () => {
5956 return supportedCoins . length === 1 ;
6057 } ;
6158
62- const startProcess = async ( ) => {
59+ const startProcess = useCallback ( async ( ) => {
6360 try {
6461 const coins = await backendAPI . getSupportedCoins ( ) ;
6562 const onlyOneCoinIsSupported = ( coins . length === 1 ) ;
@@ -73,7 +70,16 @@ export const AddAccount = () => {
7370 } catch ( err ) {
7471 console . error ( err ) ;
7572 }
76- } ;
73+ } , [ ] ) ;
74+
75+ useEffect ( ( ) => {
76+ startProcess ( ) ;
77+
78+ const unsubscribe = keystoresAPI . subscribeKeystores ( ( ) => {
79+ startProcess ( ) ;
80+ } ) ;
81+ return unsubscribe ;
82+ } , [ startProcess ] ) ;
7783
7884 const back = ( ) => {
7985 switch ( step ) {
@@ -122,6 +128,13 @@ export const AddAccount = () => {
122128 const renderContent = ( ) => {
123129 switch ( step ) {
124130 case 'select-coin' :
131+ if ( supportedCoins . length === 0 ) {
132+ return (
133+ < Message type = "info" >
134+ { t ( 'connectKeystore.promptNoName' ) }
135+ </ Message >
136+ ) ;
137+ }
125138 return (
126139 < CoinDropDown
127140 onChange = { coin => {
0 commit comments