mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
Move "should show banner" test to one function
This commit is contained in:
parent
8cde05fdc8
commit
3b729fcb0a
1 changed files with 11 additions and 18 deletions
|
@ -41,18 +41,15 @@ var Splash = injectIntl(React.createClass({
|
||||||
this.getActivity();
|
this.getActivity();
|
||||||
this.getFeaturedCustom();
|
this.getFeaturedCustom();
|
||||||
this.getNews();
|
this.getNews();
|
||||||
|
|
||||||
if (
|
|
||||||
this.state.session.flags.has_outstanding_email_confirmation &&
|
|
||||||
this.state.session.flags.confirm_email_banner) {
|
|
||||||
|
|
||||||
window.addEventListener('message', this.onMessage);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.setState({featuredCustom: []});
|
this.setState({featuredCustom: []});
|
||||||
this.setState({activity: []});
|
this.setState({activity: []});
|
||||||
this.setState({news: []});
|
this.setState({news: []});
|
||||||
this.getProjectCount();
|
this.getProjectCount();
|
||||||
|
}
|
||||||
|
if (this.shouldShowEmailConfirmation()) {
|
||||||
|
window.addEventListener('message', this.onMessage);
|
||||||
|
} else {
|
||||||
window.removeEventListener('message', this.onMessage);
|
window.removeEventListener('message', this.onMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,16 +60,10 @@ var Splash = injectIntl(React.createClass({
|
||||||
this.getActivity();
|
this.getActivity();
|
||||||
this.getFeaturedCustom();
|
this.getFeaturedCustom();
|
||||||
this.getNews();
|
this.getNews();
|
||||||
|
|
||||||
if (
|
|
||||||
this.state.session.flags.has_outstanding_email_confirmation &&
|
|
||||||
this.state.session.flags.confirm_email_banner) {
|
|
||||||
|
|
||||||
window.addEventListener('message', this.onMessage);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.getProjectCount();
|
this.getProjectCount();
|
||||||
}
|
}
|
||||||
|
if (this.shouldShowEmailConfirmation()) window.addEventListener('message', this.onMessage);
|
||||||
},
|
},
|
||||||
componentWillUnmount: function () {
|
componentWillUnmount: function () {
|
||||||
window.removeEventListener('message', this.onMessage);
|
window.removeEventListener('message', this.onMessage);
|
||||||
|
@ -147,6 +138,11 @@ var Splash = injectIntl(React.createClass({
|
||||||
new Date(new Date - 2*7*24*60*60*1000) // Two weeks ago
|
new Date(new Date - 2*7*24*60*60*1000) // Two weeks ago
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
shouldShowEmailConfirmation: function () {
|
||||||
|
return (
|
||||||
|
this.state.session.user && this.state.session.flags.has_outstanding_email_confirmation &&
|
||||||
|
this.state.session.flags.confirm_email_banner);
|
||||||
|
},
|
||||||
renderHomepageRows: function () {
|
renderHomepageRows: function () {
|
||||||
var formatMessage = this.props.intl.formatMessage;
|
var formatMessage = this.props.intl.formatMessage;
|
||||||
|
|
||||||
|
@ -288,13 +284,10 @@ var Splash = injectIntl(React.createClass({
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var featured = this.renderHomepageRows();
|
var featured = this.renderHomepageRows();
|
||||||
var showEmailConfirmation = (
|
|
||||||
this.state.session.user && this.state.session.flags.has_outstanding_email_confirmation &&
|
|
||||||
this.state.session.flags.confirm_email_banner);
|
|
||||||
var emailConfirmationStyle = {width: 500, height: 330, padding: 1};
|
var emailConfirmationStyle = {width: 500, height: 330, padding: 1};
|
||||||
return (
|
return (
|
||||||
<div className="splash">
|
<div className="splash">
|
||||||
{showEmailConfirmation ? [
|
{this.shouldShowEmailConfirmation() ? [
|
||||||
<Banner key="confirmedEmail"
|
<Banner key="confirmedEmail"
|
||||||
className="warning"
|
className="warning"
|
||||||
onRequestDismiss={this.handleDismiss.bind(this, 'confirmed_email')}>
|
onRequestDismiss={this.handleDismiss.bind(this, 'confirmed_email')}>
|
||||||
|
|
Loading…
Reference in a new issue