14
14
* limitations under the License.
15
15
*/
16
16
17
- import React , { useEffect , useRef , useState } from 'react' ;
17
+ import React , { useCallback , useEffect , useRef , useState } from 'react' ;
18
18
import { useTranslation } from 'react-i18next' ;
19
19
import * as backendAPI from '../../../api/backend' ;
20
20
import { SimpleMarkup } from '../../../utils/markup' ;
@@ -45,10 +45,6 @@ export const AddAccount = () => {
45
45
46
46
const { t } = useTranslation ( ) ;
47
47
48
- useEffect ( ( ) => {
49
- startProcess ( ) ;
50
- } , [ ] ) ;
51
-
52
48
useEffect ( ( ) => {
53
49
if ( step === 'choose-name' ) {
54
50
inputRef . current ?. focus ( ) ;
@@ -59,7 +55,7 @@ export const AddAccount = () => {
59
55
return supportedCoins . length === 1 ;
60
56
} ;
61
57
62
- const startProcess = async ( ) => {
58
+ const startProcess = useCallback ( async ( ) => {
63
59
try {
64
60
const coins = await backendAPI . getSupportedCoins ( ) ;
65
61
const onlyOneCoinIsSupported = ( coins . length === 1 ) ;
@@ -73,7 +69,16 @@ export const AddAccount = () => {
73
69
} catch ( err ) {
74
70
console . error ( err ) ;
75
71
}
76
- } ;
72
+ } , [ ] ) ;
73
+
74
+ useEffect ( ( ) => {
75
+ startProcess ( ) ;
76
+
77
+ const unsubscribe = backendAPI . syncKeystores ( ( ) => {
78
+ startProcess ( ) ;
79
+ } ) ;
80
+ return unsubscribe ;
81
+ } , [ startProcess ] ) ;
77
82
78
83
const back = ( ) => {
79
84
switch ( step ) {
@@ -122,6 +127,13 @@ export const AddAccount = () => {
122
127
const renderContent = ( ) => {
123
128
switch ( step ) {
124
129
case 'select-coin' :
130
+ if ( supportedCoins . length === 0 ) {
131
+ return (
132
+ < div className = "text-center" >
133
+ { t ( 'connectKeystore.promptNoName' ) }
134
+ </ div >
135
+ ) ;
136
+ }
125
137
return (
126
138
< CoinDropDown
127
139
onChange = { coin => {
0 commit comments