Skip to content

Commit

Permalink
Show vcard in messages
Browse files Browse the repository at this point in the history
resolves #3829
  • Loading branch information
nicodh committed May 21, 2024
1 parent fc70dfd commit 230fb59
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/renderer/components/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,36 @@ export default function Message(props: {
</div>
</div>
)
} else if (message.vcardContact) {
const { profileImage, color, displayName, addr } = message.vcardContact
const codepoint = displayName && displayName.codePointAt(0)
const initial = codepoint
? String.fromCodePoint(codepoint).toUpperCase()
: '#'
content = (
<div className={styles.vcard}>
<div
className={classNames('avatar', styles.avatar)}
aria-label={displayName}
>
{profileImage ? (
<img
alt={displayName}
className='content'
src={'data:image/jpeg;base64,' + profileImage}
/>
) : (
<div style={{ backgroundColor: color }} className='content'>
{initial}
</div>
)}
</div>
<div className={styles.contactInfo}>
<div className={styles.displayName}>{displayName}</div>
<div>{addr}</div>
</div>
</div>
)
} else {
content = (
<div dir='auto' className='text'>
Expand Down Expand Up @@ -586,6 +616,11 @@ export default function Message(props: {
const hasText = text !== null && text !== ''
const fileMime = (!isSetupmessage && message.fileMime) || null
const isWithoutText = isMediaWithoutText(fileMime, hasText, message.viewType)
const showAttachment = (message: T.Message) =>
message.file &&
!message.isSetupmessage &&
message.viewType !== 'Webxdc' &&
message.viewType !== 'Vcard'

return (
<div
Expand Down Expand Up @@ -637,7 +672,7 @@ export default function Message(props: {
{message.quote !== null && (
<Quote quote={message.quote} msgParentId={message.id} />
)}
{message.file && !isSetupmessage && message.viewType !== 'Webxdc' && (
{showAttachment(message) && (
<Attachment
text={text || undefined}
conversationType={conversationType}
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/components/message/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@
padding-right: 13px;
padding-top: 7px;
}

.vcard {
display: flex;
.avatar {
margin-bottom: 0;
}
.contactInfo {
display: flex;
flex-grow: 1;
flex-direction: column;
padding-left: 10px;
}
.displayName {
margin-bottom: 0;
margin-top: 10px;
font-weight: 200;
font-size: medium;
}
}

0 comments on commit 230fb59

Please sign in to comment.