Merge pull request #503 from msgmaxim/shorten_pubkey

Shorten pubkeys in quotations too
This commit is contained in:
Mikunj Varsani 2019-09-13 11:58:09 +10:00 committed by GitHub
commit 69eab9f196
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 5 deletions

View file

@ -20,6 +20,10 @@
font-style: italic;
}
.module-contact-name.compact {
display: block;
}
// Module: Message
.module-message {

View file

@ -11,6 +11,7 @@ interface Props {
i18n: LocalizerType;
module?: string;
boldProfileName?: Boolean;
compact?: Boolean;
}
export class ContactName extends React.Component<Props> {
@ -22,6 +23,7 @@ export class ContactName extends React.Component<Props> {
i18n,
module,
boldProfileName,
compact,
} = this.props;
const prefix = module ? module : 'module-contact-name';
@ -39,7 +41,7 @@ export class ContactName extends React.Component<Props> {
) : null;
return (
<span className={prefix} dir="auto">
<span className={classNames(prefix, compact && 'compact')} dir="auto">
{profileElement}
{shouldShowProfile ? ' ' : null}
<span

View file

@ -322,12 +322,18 @@ export class Message extends React.PureComponent<Props, State> {
return null;
}
const shortenedPubkey = `(...${authorPhoneNumber.substring(
authorPhoneNumber.length - 6
)})`;
const displayedPubkey = authorProfileName
? shortenedPubkey
: authorPhoneNumber;
return (
<div className="module-message__author">
<ContactName
phoneNumber={`(...${authorPhoneNumber.substring(
authorPhoneNumber.length - 6
)})`}
phoneNumber={displayedPubkey}
name={authorName}
profileName={authorProfileName}
module="module-message__author"
@ -590,6 +596,14 @@ export class Message extends React.PureComponent<Props, State> {
const quoteColor =
direction === 'incoming' ? authorColor : quote.authorColor;
const shortenedPubkey = `(...${quote.authorPhoneNumber.substring(
quote.authorPhoneNumber.length - 6
)})`;
const displayedPubkey = quote.authorProfileName
? shortenedPubkey
: quote.authorPhoneNumber;
return (
<Quote
i18n={i18n}
@ -597,7 +611,7 @@ export class Message extends React.PureComponent<Props, State> {
text={quote.text}
attachment={quote.attachment}
isIncoming={direction === 'incoming'}
authorPhoneNumber={quote.authorPhoneNumber}
authorPhoneNumber={displayedPubkey}
authorProfileName={quote.authorProfileName}
authorName={quote.authorName}
authorColor={quoteColor}

View file

@ -304,6 +304,7 @@ export class Quote extends React.Component<Props, State> {
name={authorName}
profileName={authorProfileName}
i18n={i18n}
compact={true}
/>
)}
</div>