fix: do not use 'anonymous' placeholder. We use the shorten pk

pull/3281/head
Audric Ackermann 5 months ago
parent fa98d0397a
commit fa8de2eee5
No known key found for this signature in database

@ -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 (
<span

@ -59,6 +59,7 @@ import {
import { CompositionTextArea } from './CompositionTextArea';
import { cleanMentions, mentionsRegex } from './UserMentions';
import { HTMLDirection } from '../../../util/i18n/rtlSupport';
import { PubKey } from '../../../session/types';
export interface ReplyingToMessageProps {
convoId: string;
@ -521,8 +522,7 @@ class CompositionBoxInner extends Component<Props, State> {
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<Props, State> {
// 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);

@ -1423,11 +1423,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
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<ConversationAttributes> {
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<ConversationAttributes> {
iconUrl,
isExpiringMessage: false,
message: window.i18n('callsIncoming', {
name: this.getNicknameOrRealUsername() || window.i18n('anonymous'),
name: this.getNicknameOrRealUsername() || PubKey.shorten(conversationId),
}),
messageSentAt: now,
title: this.getNicknameOrRealUsernameOrPlaceholder(),

@ -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');
};

@ -374,9 +374,6 @@ export function useSelectedShortenedPubkeyOrFallback() {
if (isPrivate && selected) {
return PubKey.shorten(selected);
}
if (isPrivate) {
return window.i18n('anonymous');
}
return window.i18n('unknown');
}

Loading…
Cancel
Save