mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 01:54:40 +08:00
fix(autoload-images): Bar disappears when you choose to load images
This commit is contained in:
parent
9bb181ef3e
commit
6d43c9623c
3 changed files with 42 additions and 16 deletions
|
@ -10,10 +10,31 @@ export default class AutoloadImagesHeader extends React.Component {
|
|||
message: React.PropTypes.instanceOf(Message).isRequired,
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
render() {
|
||||
const {message} = this.props;
|
||||
const {blocking} = this.state;
|
||||
|
||||
if (AutoloadImagesStore.shouldBlockImagesIn(message) === false) {
|
||||
if (blocking === false) {
|
||||
return (
|
||||
<div></div>
|
||||
);
|
||||
|
|
|
@ -15,7 +15,9 @@ class AutoloadImagesStore extends NylasStore {
|
|||
|
||||
this._whitelistEmails = {}
|
||||
this._whitelistMessageIds = {}
|
||||
this._whitelistEmailsPath = path.join(NylasEnv.getConfigDirPath(), 'autoload-images-whitelist.txt');
|
||||
|
||||
const filename = 'autoload-images-whitelist.txt';
|
||||
this._whitelistEmailsPath = path.join(NylasEnv.getConfigDirPath(), filename);
|
||||
|
||||
this._loadWhitelist();
|
||||
|
||||
|
@ -23,7 +25,7 @@ class AutoloadImagesStore extends NylasStore {
|
|||
this.listenTo(AutoloadImagesActions.permanentlyEnableImages, this._onPermanentlyEnableImages);
|
||||
|
||||
NylasEnv.config.onDidChange('core.reading.autoloadImages', () => {
|
||||
MessageBodyProcessor.resetCache()
|
||||
MessageBodyProcessor.resetCache();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,12 +48,16 @@ class AutoloadImagesStore extends NylasStore {
|
|||
if (!exists) { return; }
|
||||
|
||||
fs.readFile(this._whitelistEmailsPath, (err, body) => {
|
||||
if (err || !body) { return console.log(err); }
|
||||
if (err || !body) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
this._whitelistEmails = {}
|
||||
body.toString().split(/[\n\r]+/).forEach((email) => {
|
||||
this._whitelistEmails[Utils.toEquivalentEmailForm(email)] = true;
|
||||
});
|
||||
this.trigger();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -68,6 +74,7 @@ class AutoloadImagesStore extends NylasStore {
|
|||
_onTemporarilyEnableImages = (message) => {
|
||||
this._whitelistMessageIds[message.id] = true;
|
||||
MessageBodyProcessor.resetCache();
|
||||
this.trigger();
|
||||
}
|
||||
|
||||
_onPermanentlyEnableImages = (message) => {
|
||||
|
@ -75,6 +82,7 @@ class AutoloadImagesStore extends NylasStore {
|
|||
this._whitelistEmails[email] = true;
|
||||
MessageBodyProcessor.resetCache();
|
||||
setTimeout(this._saveWhitelist, 1);
|
||||
this.trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,5 @@
|
|||
"private": true,
|
||||
"engines": {
|
||||
"nylas": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"autolinker": "0.18.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue