mirror of
https://github.com/zhigang1992/connect.git
synced 2026-04-30 18:32:30 +08:00
fix: dont have selected address when canceling reuse, fixes #454
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
/>,
|
||||
|
||||
Reference in New Issue
Block a user