mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-03 11:36:08 +08:00
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
import { localized, React, PropTypes, DateUtils } from 'mailspring-exports';
|
|
import { Flexbox } from 'mailspring-component-kit';
|
|
import { pluckByEmail } from '../../activity/lib/activity-event-store';
|
|
|
|
class LinkTrackingMessagePopover extends React.Component {
|
|
static displayName = 'LinkTrackingMessagePopover';
|
|
|
|
static propTypes = {
|
|
message: PropTypes.object,
|
|
linkMetadata: PropTypes.object,
|
|
};
|
|
|
|
renderClickActions() {
|
|
const clicks = this.props.linkMetadata.click_data;
|
|
return clicks.map(click => {
|
|
const recipients = this.props.message.to.concat(
|
|
this.props.message.cc,
|
|
this.props.message.bcc
|
|
);
|
|
|
|
const recipient = pluckByEmail(recipients, click.recipient);
|
|
const date = new Date(0);
|
|
date.setUTCSeconds(click.timestamp);
|
|
return (
|
|
<Flexbox key={`${click.timestamp}`} className="click-action">
|
|
<div className="recipient">
|
|
{recipient ? recipient.displayName() : localized('Someone')}
|
|
</div>
|
|
<div className="spacer" />
|
|
<div className="timestamp">{DateUtils.shortTimeString(date)}</div>
|
|
</Flexbox>
|
|
);
|
|
});
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="link-tracking-message-popover" tabIndex="-1">
|
|
<div className="link-tracking-header">{localized('Clicked by:')}</div>
|
|
<div className="click-history-container">{this.renderClickActions()}</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default LinkTrackingMessagePopover;
|