From 16b8fc8620c293e2b491e795f17b70bf50226b72 Mon Sep 17 00:00:00 2001 From: Audric Ackermann <audric@loki.network> Date: Tue, 6 Oct 2020 13:56:53 +1100 Subject: [PATCH] hide shortened pubkey except for public groups --- ts/components/ConversationListItem.tsx | 1 + ts/components/MessageSearchResult.tsx | 2 ++ ts/components/conversation/ContactName.tsx | 22 ++++++++++--------- .../conversation/ConversationHeader.tsx | 2 +- ts/components/conversation/Message.tsx | 2 ++ ts/components/conversation/MessageDetail.tsx | 1 + ts/components/conversation/Quote.tsx | 2 ++ .../conversation/SafetyNumberNotification.tsx | 1 + .../conversation/TimerNotification.tsx | 1 + .../conversation/VerificationNotification.tsx | 1 + .../session/SessionMemberListItem.tsx | 3 --- 11 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index 0d2c62451..febf5e563 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -357,6 +357,7 @@ class ConversationListItem extends React.PureComponent<Props> { module="module-conversation__user" i18n={window.i18n} boldProfileName={true} + shouldShowPubkey={false} /> </div> ); diff --git a/ts/components/MessageSearchResult.tsx b/ts/components/MessageSearchResult.tsx index 0a56b0aff..936aa2211 100644 --- a/ts/components/MessageSearchResult.tsx +++ b/ts/components/MessageSearchResult.tsx @@ -68,6 +68,7 @@ export class MessageSearchResult extends React.PureComponent<Props> { profileName={from.profileName} i18n={i18n} module="module-message-search-result__header__name" + shouldShowPubkey={false} /> ); } @@ -86,6 +87,7 @@ export class MessageSearchResult extends React.PureComponent<Props> { name={to.name} profileName={to.profileName} i18n={i18n} + shouldShowPubkey={false} /> </span> </div> diff --git a/ts/components/conversation/ContactName.tsx b/ts/components/conversation/ContactName.tsx index 39f69d4c9..0f3ab3414 100644 --- a/ts/components/conversation/ContactName.tsx +++ b/ts/components/conversation/ContactName.tsx @@ -12,6 +12,7 @@ interface Props { module?: string; boldProfileName?: Boolean; compact?: Boolean; + shouldShowPubkey: Boolean; } export class ContactName extends React.Component<Props> { @@ -24,19 +25,27 @@ export class ContactName extends React.Component<Props> { module, boldProfileName, compact, + shouldShowPubkey, } = this.props; const prefix = module ? module : 'module-contact-name'; const title = name ? name : phoneNumber; - const shouldShowProfile = Boolean(profileName && !name); + const shouldShowProfile = Boolean(profileName || name); const styles = (boldProfileName ? { fontWeight: 'bold', } : {}) as React.CSSProperties; + const textProfile = profileName || name || ''; const profileElement = shouldShowProfile ? ( <span style={styles} className={`${prefix}__profile-name`}> - <Emojify text={profileName || ''} i18n={i18n} /> + <Emojify text={textProfile} i18n={i18n} /> + </span> + ) : null; + + const pubKeyElement = shouldShowPubkey ? ( + <span className={`${prefix}__profile-number`}> + <Emojify text={title} i18n={i18n} /> </span> ) : null; @@ -44,14 +53,7 @@ export class ContactName extends React.Component<Props> { <span className={classNames(prefix, compact && 'compact')} dir="auto"> {profileElement} {shouldShowProfile ? ' ' : null} - <span - className={classNames( - `${prefix}__profile-number`, - shouldShowProfile && 'italic' - )} - > - <Emojify text={title} i18n={i18n} /> - </span> + {pubKeyElement} </span> ); } diff --git a/ts/components/conversation/ConversationHeader.tsx b/ts/components/conversation/ConversationHeader.tsx index 82151ed7f..c890cec6b 100644 --- a/ts/components/conversation/ConversationHeader.tsx +++ b/ts/components/conversation/ConversationHeader.tsx @@ -181,7 +181,7 @@ class ConversationHeader extends React.Component<Props> { let title; if (profileName) { - title = `${profileName} ${window.shortenPubkey(phoneNumber)}`; + title = `${profileName}`; } else { if (name) { title = `${name}`; diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 73143a2b0..ec2a033fe 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -1169,6 +1169,7 @@ export class Message extends React.PureComponent<Props, State> { conversationType, direction, i18n, + isPublic, } = this.props; const title = authorName ? authorName : authorPhoneNumber; @@ -1192,6 +1193,7 @@ export class Message extends React.PureComponent<Props, State> { module="module-message__author" i18n={i18n} boldProfileName={true} + shouldShowPubkey={Boolean(isPublic)} /> </div> ); diff --git a/ts/components/conversation/MessageDetail.tsx b/ts/components/conversation/MessageDetail.tsx index 235deb18b..1b432c432 100644 --- a/ts/components/conversation/MessageDetail.tsx +++ b/ts/components/conversation/MessageDetail.tsx @@ -107,6 +107,7 @@ export class MessageDetail extends React.Component<Props> { name={contact.name} profileName={contact.profileName} i18n={i18n} + shouldShowPubkey={true} /> </div> {errors.map((error, index) => ( diff --git a/ts/components/conversation/Quote.tsx b/ts/components/conversation/Quote.tsx index 3737817b9..3856064d0 100644 --- a/ts/components/conversation/Quote.tsx +++ b/ts/components/conversation/Quote.tsx @@ -302,6 +302,7 @@ export class Quote extends React.Component<Props, State> { i18n, isFromMe, isIncoming, + isPublic, } = this.props; return ( @@ -320,6 +321,7 @@ export class Quote extends React.Component<Props, State> { profileName={authorProfileName} i18n={i18n} compact={true} + shouldShowPubkey={Boolean(isPublic)} /> )} </div> diff --git a/ts/components/conversation/SafetyNumberNotification.tsx b/ts/components/conversation/SafetyNumberNotification.tsx index 47e633994..e31a90b09 100644 --- a/ts/components/conversation/SafetyNumberNotification.tsx +++ b/ts/components/conversation/SafetyNumberNotification.tsx @@ -42,6 +42,7 @@ export class SafetyNumberNotification extends React.Component<Props> { profileName={contact.profileName} phoneNumber={contact.phoneNumber} module="module-verification-notification__contact" + shouldShowPubkey={true} /> </span>, ]} diff --git a/ts/components/conversation/TimerNotification.tsx b/ts/components/conversation/TimerNotification.tsx index 2d08c4497..a38a8cf23 100644 --- a/ts/components/conversation/TimerNotification.tsx +++ b/ts/components/conversation/TimerNotification.tsx @@ -51,6 +51,7 @@ export class TimerNotification extends React.Component<Props> { name={name} module="module-message__author" boldProfileName={true} + shouldShowPubkey={false} />, timespan, ]} diff --git a/ts/components/conversation/VerificationNotification.tsx b/ts/components/conversation/VerificationNotification.tsx index 0d9fca24e..43a67f797 100644 --- a/ts/components/conversation/VerificationNotification.tsx +++ b/ts/components/conversation/VerificationNotification.tsx @@ -53,6 +53,7 @@ export class VerificationNotification extends React.Component<Props> { profileName={contact.profileName} phoneNumber={contact.phoneNumber} module="module-verification-notification__contact" + shouldShowPubkey={true} />, ]} i18n={i18n} diff --git a/ts/components/session/SessionMemberListItem.tsx b/ts/components/session/SessionMemberListItem.tsx index 7497800b5..0cd21a1c7 100644 --- a/ts/components/session/SessionMemberListItem.tsx +++ b/ts/components/session/SessionMemberListItem.tsx @@ -49,8 +49,6 @@ export class SessionMemberListItem extends React.Component<Props, State> { const { isSelected } = this.state; const name = this.props.member.authorProfileName; - const pubkey = this.props.member.authorPhoneNumber; - const shortPubkey = window.shortenPubkey(pubkey); return ( <div @@ -67,7 +65,6 @@ export class SessionMemberListItem extends React.Component<Props, State> { {this.renderAvatar()} </span> <span className="session-member-item__name">{name}</span> - <span className="session-member-item__pubkey">{shortPubkey}</span> </div> <span className={classNames(