Mailspring/app/internal_packages/open-tracking/lib/open-tracking-message-popover.jsx

44 lines
1.4 KiB
React
Raw Normal View History

import { React, PropTypes, DateUtils } from 'mailspring-exports';
2017-09-27 02:46:00 +08:00
import { Flexbox } from 'mailspring-component-kit';
import { pluckByEmail } from '../../activity/lib/activity-event-store';
class OpenTrackingMessagePopover extends React.Component {
static displayName = 'OpenTrackingMessagePopover';
static propTypes = {
2017-09-27 02:33:08 +08:00
message: PropTypes.object,
openMetadata: PropTypes.object,
};
renderOpenActions() {
const opens = this.props.openMetadata.open_data;
2017-09-27 02:33:08 +08:00
return opens.map(open => {
const recipients = this.props.message.to.concat(
this.props.message.cc,
this.props.message.bcc
);
const recipient = pluckByEmail(recipients, open.recipient);
const date = new Date(0);
date.setUTCSeconds(open.timestamp);
return (
<Flexbox key={`${open.timestamp}`} className="open-action">
2017-09-27 02:33:08 +08:00
<div className="recipient">{recipient ? recipient.displayName() : 'Someone'}</div>
<div className="spacer" />
2017-09-27 02:33:08 +08:00
<div className="timestamp">{DateUtils.shortTimeString(date)}</div>
</Flexbox>
);
});
}
render() {
return (
2017-09-27 02:33:08 +08:00
<div className="open-tracking-message-popover" tabIndex="-1">
<div className="open-tracking-header">Opened by:</div>
2017-09-27 02:33:08 +08:00
<div className="open-history-container">{this.renderOpenActions()}</div>
</div>
);
}
}
export default OpenTrackingMessagePopover;