mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 14:20:38 +08:00
9378f4480c
Conflicts: internal_packages/inbox-activity-bar/lib/activity-bar-long-poll-item.cjsx
39 lines
1.2 KiB
CoffeeScript
39 lines
1.2 KiB
CoffeeScript
React = require "react"
|
|
{Actions} = require 'nylas-exports'
|
|
crypto = require "crypto"
|
|
|
|
class ContactChip extends React.Component
|
|
@displayName: "ContactChip"
|
|
|
|
render: =>
|
|
className = "contact-chip"
|
|
if @props.clickable
|
|
className += " clickable"
|
|
|
|
<span className={className} onClick={@_onClick}>
|
|
<span className="contact-name">{@_getParticipantDisplay()}</span>
|
|
</span>
|
|
|
|
_onClick: =>
|
|
return unless @props.clickable
|
|
clipboard = require('clipboard')
|
|
clipboard.writeText(@props.participant.email)
|
|
Actions.postNotification({message: "Copied #{@props.participant.email} to clipboard", type: 'success'})
|
|
|
|
_getParticipantDisplay: =>
|
|
@props.participant.displayName()
|
|
|
|
shouldComponentUpdate: (newProps, newState) =>
|
|
(newProps.participant?.email != @props.participant?.email) ||
|
|
(newProps.participant?.name != @props.participant?.name)
|
|
|
|
componentWillMount: =>
|
|
email = @props.participant.email.toLowerCase()
|
|
@md5 = crypto.createHash('md5').update(email).digest('hex')
|
|
|
|
nameMD5 = crypto.createHash('md5').update(email + @props.participant.name).digest('hex')
|
|
n = Math.floor(parseInt(nameMD5.slice(0, 2), 16) * 360/256)
|
|
@bg = "hsl(#{n}, 50%, 50%)"
|
|
|
|
|
|
module.exports = ContactChip
|