Skip to content

Commit 1d3cc93

Browse files
committed
frontend/add-account: ask user to connect BitBox02 to continue
Since watchonly, one can enter this screen without a keystore connected. If so, we ask the user to connect to proceed.
1 parent 5bda68d commit 1d3cc93

File tree

1 file changed

+20
-7
lines changed
  • frontends/web/src/routes/account/add

1 file changed

+20
-7
lines changed

frontends/web/src/routes/account/add/add.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useEffect, useRef, useState } from 'react';
17+
import React, { useCallback, useEffect, useRef, useState } from 'react';
1818
import { useTranslation } from 'react-i18next';
1919
import * as backendAPI from '../../../api/backend';
20+
import * as keystoresAPI from '../../../api/keystores';
2021
import { SimpleMarkup } from '../../../utils/markup';
2122
import { Message } from '../../../components/message/message';
2223
import { 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

Comments
 (0)