mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-25 01:36:06 +08:00
9dd7a9600a
Fix broken links in link tracking and read receipts Fix bug in email frame where it wouldn't adjust the height even when content changed MessageItem bodies automatically clear the MessageBodyProcessor cache when the message contents (including metadata) change. Remove unused Account stuff from nylas-observables Plugins appIds properly read if there's an environment set
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import {React} from 'nylas-exports'
|
|
import {RetinaImg} from 'nylas-component-kit'
|
|
import {PLUGIN_ID} from './open-tracking-constants'
|
|
|
|
export default class OpenTrackingMessageStatus extends React.Component {
|
|
static displayName = "OpenTrackingMessageStatus";
|
|
|
|
static propTypes = {
|
|
message: React.PropTypes.object.isRequired,
|
|
};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = this._getStateFromMessage(props.message)
|
|
}
|
|
|
|
_getStateFromMessage(message) {
|
|
const metadata = message.metadataForPluginId(PLUGIN_ID);
|
|
if (!metadata) {
|
|
return {hasMetadata: false, opened: false}
|
|
}
|
|
return {
|
|
hasMetadata: true,
|
|
opened: metadata.open_count > 0,
|
|
};
|
|
}
|
|
|
|
static containerStyles = {
|
|
paddingTop: 4,
|
|
};
|
|
|
|
renderImage() {
|
|
return (
|
|
<RetinaImg
|
|
className={this.state.opened ? "opened" : "unopened"}
|
|
url="nylas://open-tracking/assets/icon-composer-eye@2x.png"
|
|
mode={RetinaImg.Mode.ContentIsMask} />
|
|
);
|
|
}
|
|
|
|
render() {
|
|
if (!this.state.hasMetadata) { return false }
|
|
const txt = this.state.opened ? "Read" : "Unread";
|
|
const title = this.state.opened ? "This message has been read at least once" : "This message has not been read";
|
|
return (
|
|
<span title={title} className={`read-receipt-message-status ${txt}`}>{this.renderImage()} {txt}</span>
|
|
)
|
|
}
|
|
}
|