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 (
);
}
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 (
{this.renderImage()} {txt}
)
}
}