fix: dont have selected address when canceling reuse, fixes #454

This commit is contained in:
Hank Stoever
2020-07-14 07:13:53 -07:00
parent 19fbf4efdc
commit 27f8f61654
2 changed files with 10 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Identity } from '@blockstack/keychain';
import { Text, Flex, FlexProps, Spinner } from '@blockstack/ui';
import { ScreenPaths } from '@store/onboarding/types';
@@ -46,14 +46,21 @@ const AccountItem = ({ label, address, selectedAddress, ...rest }: AccountItemPr
interface AccountsProps {
identities: Identity[];
identityIndex?: number;
showAddAccount?: boolean;
next?: (identityIndex: number) => void;
}
export const Accounts = ({ identities, showAddAccount, next }: AccountsProps) => {
export const Accounts = ({ identities, showAddAccount, identityIndex, next }: AccountsProps) => {
const [selectedAddress, setSelectedAddress] = useState<null | string>(null);
const { doChangeScreen } = useAnalytics();
useEffect(() => {
if (typeof identityIndex === 'undefined' && selectedAddress) {
setSelectedAddress(null);
}
}, [identityIndex]);
return (
<Flex flexDirection="column">
{identities.map(({ defaultUsername, address }, key) => {

View File

@@ -122,6 +122,7 @@ export const ChooseAccount: React.FC<ChooseAccountProps> = ({ next }) => {
`to use with ${appName}`,
<Accounts
identities={identities}
identityIndex={identityIndex}
next={(identityIndex: number) => didSelectAccount({ identityIndex })}
showAddAccount
/>,