diff --git a/packages/mask/shared-ui/locales/en-US.json b/packages/mask/shared-ui/locales/en-US.json index 5471db0b8fa6..8c6ba2e77bdf 100644 --- a/packages/mask/shared-ui/locales/en-US.json +++ b/packages/mask/shared-ui/locales/en-US.json @@ -64,7 +64,8 @@ "compose_encrypt_visible_to_all_sub": "Everyone", "compose_encrypt_visible_to_private": "Private", "compose_encrypt_visible_to_private_sub": "Just Me", - "compose_shared_friends": "1 friend", + "compose_shared_friends_one": "1 friend", + "compose_shared_friends_other": "{{count}} friends", "compose_encrypt_visible_to_share": "Share with", "compose_encrypt_visible_to_share_sub": "Just Selected Contacts", "compose_encrypt_share_dialog_empty": "No encrypted friends, you can try searching.", diff --git a/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx b/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx index 50fba1981300..1287d155aa87 100644 --- a/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx +++ b/packages/mask/src/components/CompositionDialog/EncryptionTargetSelector.tsx @@ -114,7 +114,10 @@ export function EncryptionTargetSelector(props: EncryptionTargetSelectorProps) { const selectedTitle = () => { const selected = props.target const shareWithNum = props.selectedRecipientLength - if (selected === EncryptionTargetType.E2E) return t('compose_shared_friends', { count: shareWithNum }) + if (selected === EncryptionTargetType.E2E) + return shareWithNum > 1 + ? t('compose_shared_friends_other', { count: shareWithNum }) + : t('compose_shared_friends_one') else if (selected === EncryptionTargetType.Public) return t('compose_encrypt_visible_to_all') else if (selected === EncryptionTargetType.Self) return t('compose_encrypt_visible_to_private') unreachable(selected) diff --git a/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx b/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx index 142868c4d93b..cbd53aa2d57a 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipients.tsx @@ -59,11 +59,7 @@ export function SelectRecipientsUI(props: SelectRecipientsUIProps) { }} open={open} items={searchedList || EMPTY_LIST} - selected={ - searchedList?.filter((x) => - selected.some((i) => i.linkedPersona?.publicKeyAsHex === x.linkedPersona?.publicKeyAsHex), - ) || EMPTY_LIST - } + selected={selected} disabled={false} submitDisabled={false} onSubmit={onClose} diff --git a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx index 291f14d9658d..96aaee4656cf 100644 --- a/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx +++ b/packages/mask/src/components/shared/SelectRecipients/SelectRecipientsDialog.tsx @@ -7,6 +7,7 @@ import type { ProfileInformation as Profile, ProfileInformationFromNextID } from import { useI18N } from '../../../utils' import { ProfileInList } from './ProfileInList' import { SearchEmptyIcon, SearchIcon } from '@masknet/icons' +import { uniqBy } from 'lodash-unified' const useStyles = makeStyles()((theme) => ({ root: { @@ -111,9 +112,11 @@ export function SelectRecipientsDialogUI(props: SelectRecipientsDialogUIProps) { ignoreLocation: true, threshold: 0, }) - return search === '' ? items : fuse.search(search).map((item) => item.item) + return uniqBy( + (search === '' ? items : fuse.search(search).map((item) => item.item)).concat(props.selected), + (x) => x.linkedPersona?.rawPublicKey.toLowerCase(), + ) }, [search, items]) - return (