diff --git a/ts/components/conversation/ContactName.tsx b/ts/components/conversation/ContactName.tsx index 261b4715e..4ac500ed3 100644 --- a/ts/components/conversation/ContactName.tsx +++ b/ts/components/conversation/ContactName.tsx @@ -6,6 +6,7 @@ import { useNicknameOrProfileNameOrShortenedPubkey, } from '../../hooks/useParamSelector'; import { Emojify } from './Emojify'; +import { PubKey } from '../../session/types'; type Props = { pubkey: string; @@ -41,7 +42,7 @@ export const ContactName = (props: Props) => { } : commonStyles ) as CSSProperties; - const textProfile = profileName || name || convoName || window.i18n('anonymous'); + const textProfile = profileName || name || convoName || PubKey.shorten(pubkey); return ( { const allMembers = allPubKeys.map(pubKey => { const convo = ConvoHub.use().get(pubKey); - const profileName = - convo?.getNicknameOrRealUsernameOrPlaceholder() || window.i18n('anonymous'); + const profileName = convo?.getNicknameOrRealUsernameOrPlaceholder() || PubKey.shorten(pubKey); return { id: pubKey, @@ -539,7 +539,7 @@ class CompositionBoxInner extends Component { // Transform the users to what react-mentions expects const mentionsData = members.map(user => ({ - display: user.authorProfileName || window.i18n('anonymous'), + display: user.authorProfileName || PubKey.shorten(user.id), id: user.id, })); callback(mentionsData); diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 83d37a84e..3f53774c5 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1423,11 +1423,6 @@ export class ConversationModel extends Backbone.Model { return this.getNickname() || this.getRealSessionUsername(); } - /** - * @returns `getNickname` if a private convo and a nickname is set, or `getRealSessionUsername` - * - * Can also a localized 'Anonymous' for an unknown private chat and localized 'Unknown' for an unknown group (open/closed) - */ public getNicknameOrRealUsernameOrPlaceholder(): string { const nickOrReal = this.getNickname() || this.getRealSessionUsername(); @@ -1435,7 +1430,7 @@ export class ConversationModel extends Backbone.Model { return nickOrReal; } if (this.isPrivate()) { - return window.i18n('anonymous'); + return PubKey.shorten(this.id); } if (this.isPublic()) { return window.i18n('communityUnknown'); @@ -1981,7 +1976,7 @@ export class ConversationModel extends Backbone.Model { iconUrl, isExpiringMessage: false, message: window.i18n('callsIncoming', { - name: this.getNicknameOrRealUsername() || window.i18n('anonymous'), + name: this.getNicknameOrRealUsername() || PubKey.shorten(conversationId), }), messageSentAt: now, title: this.getNicknameOrRealUsernameOrPlaceholder(), diff --git a/ts/state/selectors/messages.ts b/ts/state/selectors/messages.ts index 6fada5564..6e7637d28 100644 --- a/ts/state/selectors/messages.ts +++ b/ts/state/selectors/messages.ts @@ -11,6 +11,7 @@ import { StateType } from '../reducer'; import { getIsMessageSelected, getMessagePropsByMessageId } from './conversations'; import { useSelectedIsPrivate } from './selectedConversation'; import { LastMessageStatusType } from '../ducks/types'; +import { PubKey } from '../../session/types'; function useMessagePropsByMessageId(messageId: string | undefined) { return useSelector((state: StateType) => getMessagePropsByMessageId(state, messageId)); @@ -34,12 +35,15 @@ export const useAuthorProfileName = (messageId: string): string | null => { if (!msg || !senderProps) { return null; } + const { sender } = msg.propsForMessage; - const senderIsUs = msg.propsForMessage.sender === UserUtils.getOurPubKeyStrFromCache(); + const senderIsUs = sender === UserUtils.getOurPubKeyStrFromCache(); const authorProfileName = senderIsUs ? window.i18n('you') - : senderProps.nickname || senderProps.displayNameInProfile || window.i18n('anonymous'); + : senderProps.nickname || + senderProps.displayNameInProfile || + PubKey.shorten(sender); return authorProfileName || window.i18n('unknown'); }; diff --git a/ts/state/selectors/selectedConversation.ts b/ts/state/selectors/selectedConversation.ts index 3d52e8ed6..f6178c64d 100644 --- a/ts/state/selectors/selectedConversation.ts +++ b/ts/state/selectors/selectedConversation.ts @@ -374,9 +374,6 @@ export function useSelectedShortenedPubkeyOrFallback() { if (isPrivate && selected) { return PubKey.shorten(selected); } - if (isPrivate) { - return window.i18n('anonymous'); - } return window.i18n('unknown'); }