diff --git a/src/components/addresses/picker/AddressPicker.tsx b/src/components/addresses/picker/AddressPicker.tsx index 7783f04..e73ac2e 100644 --- a/src/components/addresses/picker/AddressPicker.tsx +++ b/src/components/addresses/picker/AddressPicker.tsx @@ -80,8 +80,8 @@ // 'exact address' match is prepended to these options dynamically. const { wallets, addressList } = useWallets(); const { contacts, contactAddressList } = useContacts(); - const options = useMemo(() => getOptions(t, wallets, contacts), - [t, wallets, contacts]); + const options = useMemo(() => getOptions(t, wallets, contacts, noNames), + [t, wallets, contacts, noNames]); // Check if the input text is an exact address. If it is, create an extra item // to prepend to the list. Note that the 'exact address' item is NOT shown if diff --git a/src/components/addresses/picker/options.ts b/src/components/addresses/picker/options.ts index 30749bb..aa86678 100644 --- a/src/components/addresses/picker/options.ts +++ b/src/components/addresses/picker/options.ts @@ -69,12 +69,11 @@ * options. */ function getWalletOptions( wallets: WalletMap, - contacts: ContactMap + contacts: ContactMap, + noNames?: boolean ): WalletOptions { const categorised: Record = {}; const uncategorised: OptionValue[] = []; - const contactValues: OptionValue[] = Object.values(contacts) - .map(contact => getAddressItem({ contact }, "contact")); // Go through all wallets and group them for (const id in wallets) { @@ -93,6 +92,11 @@ } } + // Add the contacts too, filtering out names if noNames is set + const contactValues: OptionValue[] = Object.values(contacts) + .filter(c => noNames ? !c.isName : true) + .map(contact => getAddressItem({ contact }, "contact")); + // Sort the wallets by balance descending, and then by address ascending. // Since this uses keyedNullSort, which depends on ant-design's implicit // reversing behaviour, the array is reversed after sorting here. As such, @@ -125,10 +129,11 @@ t: TFunction, wallets: WalletMap, contactMap: ContactMap, + noNames?: boolean ): Option[] { // Wallet options const { categorised, uncategorised, categoryCount, contacts } - = getWalletOptions(wallets, contactMap); + = getWalletOptions(wallets, contactMap, noNames); // Sort the wallet categories in a human-friendly manner const sortedCategories = Object.keys(categorised);