Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions frontends/web/src/routes/account/add/add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

import React, { useEffect, useRef, useState } from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import * as backendAPI from '../../../api/backend';
import * as keystoresAPI from '../../../api/keystores';
import { SimpleMarkup } from '../../../utils/markup';
import { Message } from '../../../components/message/message';
import { Button, Input } from '../../../components/forms';
Expand Down Expand Up @@ -45,10 +46,6 @@ export const AddAccount = () => {

const { t } = useTranslation();

useEffect(() => {
startProcess();
}, []);

useEffect(() => {
if (step === 'choose-name') {
inputRef.current?.focus();
Expand All @@ -59,7 +56,7 @@ export const AddAccount = () => {
return supportedCoins.length === 1;
};

const startProcess = async () => {
const startProcess = useCallback(async () => {
try {
const coins = await backendAPI.getSupportedCoins();
const onlyOneCoinIsSupported = (coins.length === 1);
Expand All @@ -73,7 +70,16 @@ export const AddAccount = () => {
} catch (err) {
console.error(err);
}
};
}, []);

useEffect(() => {
startProcess();

const unsubscribe = keystoresAPI.subscribeKeystores(() => {
startProcess();
});
return unsubscribe;
}, [startProcess]);

const back = () => {
switch (step) {
Expand Down Expand Up @@ -122,6 +128,13 @@ export const AddAccount = () => {
const renderContent = () => {
switch (step) {
case 'select-coin':
if (supportedCoins.length === 0) {
return (
<Message type="info">
{t('connectKeystore.promptNoName')}
</Message>
);
}
return (
<CoinDropDown
onChange={coin => {
Expand Down