2016-03-01 10:47:22 +08:00
|
|
|
import React from 'react';
|
2016-10-18 08:59:33 +08:00
|
|
|
import {Message} from 'nylas-exports';
|
|
|
|
|
2016-03-01 10:47:22 +08:00
|
|
|
import AutoloadImagesStore from './autoload-images-store';
|
|
|
|
import Actions from './autoload-images-actions';
|
|
|
|
|
|
|
|
export default class AutoloadImagesHeader extends React.Component {
|
|
|
|
static displayName = 'AutoloadImagesHeader';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
message: React.PropTypes.instanceOf(Message).isRequired,
|
|
|
|
}
|
|
|
|
|
2016-03-08 10:18:57 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
blocking: AutoloadImagesStore.shouldBlockImagesIn(this.props.message),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this._unlisten = AutoloadImagesStore.listen(() => {
|
|
|
|
const blocking = AutoloadImagesStore.shouldBlockImagesIn(this.props.message);
|
|
|
|
if (blocking !== this.state.blocking) {
|
|
|
|
this.setState({blocking});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this._unlisten();
|
|
|
|
}
|
|
|
|
|
2016-03-01 10:47:22 +08:00
|
|
|
render() {
|
|
|
|
const {message} = this.props;
|
2016-03-08 10:18:57 +08:00
|
|
|
const {blocking} = this.state;
|
2016-03-01 10:47:22 +08:00
|
|
|
|
2016-03-08 10:18:57 +08:00
|
|
|
if (blocking === false) {
|
2016-03-01 10:47:22 +08:00
|
|
|
return (
|
2016-10-18 08:59:33 +08:00
|
|
|
<div />
|
2016-03-01 10:47:22 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="autoload-images-header">
|
2016-05-07 07:24:40 +08:00
|
|
|
<a className="option" onClick={() => Actions.temporarilyEnableImages(message)}>
|
2016-03-01 10:47:22 +08:00
|
|
|
Show Images
|
|
|
|
</a>
|
|
|
|
<span style={{paddingLeft: 10, paddingRight: 10}}>|</span>
|
2016-05-07 07:24:40 +08:00
|
|
|
<a className="option" onClick={() => Actions.permanentlyEnableImages(message)}>
|
2016-03-01 10:47:22 +08:00
|
|
|
Always show images from {message.fromContact().toString()}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|