Show contact name when you reply to message with a contact
This commit is contained in:
parent
cdfe4d76b1
commit
8beeef4d10
3 changed files with 16 additions and 8 deletions
|
@ -711,13 +711,21 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
async makeQuote(quotedMessage) {
|
async makeQuote(quotedMessage) {
|
||||||
|
const { getName } = Signal.Types.Contact;
|
||||||
const contact = quotedMessage.getContact();
|
const contact = quotedMessage.getContact();
|
||||||
const attachments = quotedMessage.get('attachments');
|
const attachments = quotedMessage.get('attachments');
|
||||||
|
|
||||||
|
const body = quotedMessage.get('body');
|
||||||
|
const embeddedContact = quotedMessage.get('contact');
|
||||||
|
const embeddedContactName =
|
||||||
|
embeddedContact && embeddedContact.length > 0
|
||||||
|
? getName(embeddedContact[0])
|
||||||
|
: '';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
author: contact.id,
|
author: contact.id,
|
||||||
id: quotedMessage.get('sent_at'),
|
id: quotedMessage.get('sent_at'),
|
||||||
text: quotedMessage.get('body'),
|
text: body || embeddedContactName,
|
||||||
attachments: await Promise.all(
|
attachments: await Promise.all(
|
||||||
(attachments || []).map(async attachment => {
|
(attachments || []).map(async attachment => {
|
||||||
const { contentType } = attachment;
|
const { contentType } = attachment;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Contact } from '../../types/Contact';
|
import { Contact, getName } from '../../types/Contact';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
contact: Contact;
|
contact: Contact;
|
||||||
|
@ -13,11 +13,6 @@ function getInitials(name: string): string {
|
||||||
return name.trim()[0] || '#';
|
return name.trim()[0] || '#';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName(contact: Contact): string {
|
|
||||||
const { name, organization } = contact;
|
|
||||||
return (name && name.displayName) || organization || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export class EmbeddedContact extends React.Component<Props, {}> {
|
export class EmbeddedContact extends React.Component<Props, {}> {
|
||||||
public renderAvatar() {
|
public renderAvatar() {
|
||||||
const { contact } = this.props;
|
const { contact } = this.props;
|
||||||
|
@ -26,7 +21,7 @@ export class EmbeddedContact extends React.Component<Props, {}> {
|
||||||
const path = avatar && avatar.avatar && avatar.avatar.path;
|
const path = avatar && avatar.avatar && avatar.avatar.path;
|
||||||
if (!path) {
|
if (!path) {
|
||||||
const name = getName(contact);
|
const name = getName(contact);
|
||||||
const initials = getInitials(name);
|
const initials = getInitials(name || '');
|
||||||
return (
|
return (
|
||||||
<div className="image-container">
|
<div className="image-container">
|
||||||
<div className="default-avatar">{initials}</div>
|
<div className="default-avatar">{initials}</div>
|
||||||
|
|
|
@ -97,3 +97,8 @@ export function contactSelector(
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getName(contact: Contact): string | null {
|
||||||
|
const { name, organization } = contact;
|
||||||
|
return (name && name.displayName) || organization || null;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue