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, useNicknameOrProfileNameOrShortenedPubkey,
} from '../../hooks/useParamSelector'; } from '../../hooks/useParamSelector';
import { Emojify } from './Emojify'; import { Emojify } from './Emojify';
import { PubKey } from '../../session/types';
type Props = { type Props = {
pubkey: string; pubkey: string;
@ -41,7 +42,7 @@ export const ContactName = (props: Props) => {
} }
: commonStyles : commonStyles
) as CSSProperties; ) as CSSProperties;
const textProfile = profileName || name || convoName || window.i18n('anonymous'); const textProfile = profileName || name || convoName || PubKey.shorten(pubkey);
return ( return (
<span <span

@ -59,6 +59,7 @@ import {
import { CompositionTextArea } from './CompositionTextArea'; import { CompositionTextArea } from './CompositionTextArea';
import { cleanMentions, mentionsRegex } from './UserMentions'; import { cleanMentions, mentionsRegex } from './UserMentions';
import { HTMLDirection } from '../../../util/i18n/rtlSupport'; import { HTMLDirection } from '../../../util/i18n/rtlSupport';
import { PubKey } from '../../../session/types';
export interface ReplyingToMessageProps { export interface ReplyingToMessageProps {
convoId: string; convoId: string;
@ -521,8 +522,7 @@ class CompositionBoxInner extends Component<Props, State> {
const allMembers = allPubKeys.map(pubKey => { const allMembers = allPubKeys.map(pubKey => {
const convo = ConvoHub.use().get(pubKey); const convo = ConvoHub.use().get(pubKey);
const profileName = const profileName = convo?.getNicknameOrRealUsernameOrPlaceholder() || PubKey.shorten(pubKey);
convo?.getNicknameOrRealUsernameOrPlaceholder() || window.i18n('anonymous');
return { return {
id: pubKey, id: pubKey,
@ -539,7 +539,7 @@ class CompositionBoxInner extends Component<Props, State> {
// Transform the users to what react-mentions expects // Transform the users to what react-mentions expects
const mentionsData = members.map(user => ({ const mentionsData = members.map(user => ({
display: user.authorProfileName || window.i18n('anonymous'), display: user.authorProfileName || PubKey.shorten(user.id),
id: user.id, id: user.id,
})); }));
callback(mentionsData); callback(mentionsData);

@ -1423,11 +1423,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return this.getNickname() || this.getRealSessionUsername(); 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 { public getNicknameOrRealUsernameOrPlaceholder(): string {
const nickOrReal = this.getNickname() || this.getRealSessionUsername(); const nickOrReal = this.getNickname() || this.getRealSessionUsername();
@ -1435,7 +1430,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return nickOrReal; return nickOrReal;
} }
if (this.isPrivate()) { if (this.isPrivate()) {
return window.i18n('anonymous'); return PubKey.shorten(this.id);
} }
if (this.isPublic()) { if (this.isPublic()) {
return window.i18n('communityUnknown'); return window.i18n('communityUnknown');
@ -1981,7 +1976,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
iconUrl, iconUrl,
isExpiringMessage: false, isExpiringMessage: false,
message: window.i18n('callsIncoming', { message: window.i18n('callsIncoming', {
name: this.getNicknameOrRealUsername() || window.i18n('anonymous'), name: this.getNicknameOrRealUsername() || PubKey.shorten(conversationId),
}), }),
messageSentAt: now, messageSentAt: now,
title: this.getNicknameOrRealUsernameOrPlaceholder(), title: this.getNicknameOrRealUsernameOrPlaceholder(),

@ -11,6 +11,7 @@ import { StateType } from '../reducer';
import { getIsMessageSelected, getMessagePropsByMessageId } from './conversations'; import { getIsMessageSelected, getMessagePropsByMessageId } from './conversations';
import { useSelectedIsPrivate } from './selectedConversation'; import { useSelectedIsPrivate } from './selectedConversation';
import { LastMessageStatusType } from '../ducks/types'; import { LastMessageStatusType } from '../ducks/types';
import { PubKey } from '../../session/types';
function useMessagePropsByMessageId(messageId: string | undefined) { function useMessagePropsByMessageId(messageId: string | undefined) {
return useSelector((state: StateType) => getMessagePropsByMessageId(state, messageId)); return useSelector((state: StateType) => getMessagePropsByMessageId(state, messageId));
@ -34,12 +35,15 @@ export const useAuthorProfileName = (messageId: string): string | null => {
if (!msg || !senderProps) { if (!msg || !senderProps) {
return null; return null;
} }
const { sender } = msg.propsForMessage;
const senderIsUs = msg.propsForMessage.sender === UserUtils.getOurPubKeyStrFromCache(); const senderIsUs = sender === UserUtils.getOurPubKeyStrFromCache();
const authorProfileName = senderIsUs const authorProfileName = senderIsUs
? window.i18n('you') ? window.i18n('you')
: senderProps.nickname || senderProps.displayNameInProfile || window.i18n('anonymous'); : senderProps.nickname ||
senderProps.displayNameInProfile ||
PubKey.shorten(sender);
return authorProfileName || window.i18n('unknown'); return authorProfileName || window.i18n('unknown');
}; };

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

Loading…
Cancel
Save