mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
fix(phishing): Tie to MessageStore so it works when msgs aren't ready
This commit is contained in:
parent
84b92af0e7
commit
092fb99a17
1 changed files with 22 additions and 6 deletions
|
@ -15,18 +15,34 @@ class PhishingIndicator extends React.Component {
|
|||
// Adding a displayName to a React component helps for debugging.
|
||||
static displayName = 'PhishingIndicator';
|
||||
|
||||
// @propTypes is an object which validates the datatypes of properties that
|
||||
// this React component can receive.
|
||||
static propTypes = {
|
||||
thread: React.PropTypes.object.isRequired,
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
message: MessageStore.items()[0],
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
this._unlisten = MessageStore.listen(this._onMessagesChanged);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._unlisten) {
|
||||
this._unlisten();
|
||||
}
|
||||
}
|
||||
|
||||
_onMessagesChanged = () => {
|
||||
this.setState({
|
||||
message: MessageStore.items()[0],
|
||||
});
|
||||
}
|
||||
|
||||
// A React component's `render` method returns a virtual DOM element described
|
||||
// in CJSX. `render` is deterministic: with the same input, it will always
|
||||
// render the same output. Here, the input is provided by @isPhishingAttempt.
|
||||
// `@state` and `@props` are popular inputs as well.
|
||||
render() {
|
||||
const message = MessageStore.items()[0];
|
||||
const {message} = this.state;
|
||||
|
||||
// This package's strategy to ascertain whether or not the email is a
|
||||
// phishing attempt boils down to checking the `replyTo` attributes on
|
||||
|
|
Loading…
Reference in a new issue