Skip to content

Commit

Permalink
Merge branch 'dup-fingerprint'
Browse files Browse the repository at this point in the history
  • Loading branch information
benma committed Dec 5, 2023
2 parents a72f693 + 08ff081 commit 22a4003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frontends/web/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { apiPost } from '../../utils/request';
import Logo, { AppLogoInverted } from '../icon/logo';
import { useLocation } from 'react-router';
import { CloseXWhite } from '../icon';
import { getAccountsByKeystore, isBitcoinOnly } from '../../routes/account/utils';
import { getAccountsByKeystore, isAmbiguiousName, isBitcoinOnly } from '../../routes/account/utils';
import { SkipForTesting } from '../../routes/device/components/skipfortesting';
import { Store } from '../../decorators/store';
import style from './sidebar.module.css';
Expand Down Expand Up @@ -215,6 +215,12 @@ class Sidebar extends Component<Props> {
<div className={style.sidebarHeaderContainer}>
<span className={style.sidebarHeader} hidden={!keystore.accounts.length}>
{t('sidebar.accounts')} - {keystore.keystore.name}
{ isAmbiguiousName(keystore.keystore.name, accountsByKeystore) ? (
// Disambiguate accounts group by adding the fingerprint.
// The most common case where this would happen is when adding accounts from the
// same seed using different passphrases.
<> ({keystore.keystore.rootFingerprint})</>
) : null }
</span>
</div>

Expand Down
5 changes: 5 additions & 0 deletions frontends/web/src/routes/account/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,8 @@ export function getAccountsByKeystore(accounts: IAccount[]): TAccountsByKeystore
return acc;
}, {} as Record<string, TAccountsByKeystore>));
}

// Returns true if more than one keystore has the given name.
export function isAmbiguiousName(name: string, accounts: TAccountsByKeystore[]): boolean {
return accounts.filter(keystore => keystore.keystore.name === name).length > 1;
}

0 comments on commit 22a4003

Please sign in to comment.