Commit 345540aa authored by Ray Schamp's avatar Ray Schamp

Organize view methods

Proposing this ordering: attributes, lifecycle, getters, handlers, rendering
parent 0e515c14
...@@ -30,25 +30,11 @@ var Splash = injectIntl(React.createClass({ ...@@ -30,25 +30,11 @@ var Splash = injectIntl(React.createClass({
featuredGlobal: {} featuredGlobal: {}
}; };
}, },
getGlobalHomepageRows: function () {
this.api({
uri: '/proxy/featured'
}, function (err, body) {
if (!err) this.setState({featuredGlobal: body});
}.bind(this));
},
getCustomHomepageRows: function () {
this.api({
uri: '/proxy/users/' + this.state.session.user.id + '/featured'
}, function (err, body) {
if (!err) this.setState({featuredCustom: body});
}.bind(this));
},
componentDidUpdate: function (prevProps, prevState) { componentDidUpdate: function (prevProps, prevState) {
if (this.state.session.user != prevState.session.user) { if (this.state.session.user != prevState.session.user) {
if (this.state.session.user) { if (this.state.session.user) {
this.getActivity(); this.getActivity();
this.getCustomHomepageRows(); this.getFeaturedCustom();
this.getNews(); this.getNews();
} else { } else {
this.setState({featuredCustom: []}); this.setState({featuredCustom: []});
...@@ -57,27 +43,41 @@ var Splash = injectIntl(React.createClass({ ...@@ -57,27 +43,41 @@ var Splash = injectIntl(React.createClass({
} }
}, },
componentDidMount: function () { componentDidMount: function () {
this.getGlobalHomepageRows(); this.getFeaturedGlobal();
if (this.state.session.user) { if (this.state.session.user) {
this.getActivity(); this.getActivity();
this.getCustomHomepageRows(); this.getFeaturedCustom();
this.getNews(); this.getNews();
} else { } else {
this.getProjectCount(); this.getProjectCount();
} }
}, },
getNews: function () { getActivity: function () {
this.api({ this.api({
uri: '/news?limit=3' uri: '/proxy/users/' + this.state.session.user.username + '/activity?limit=5'
}, function (err, body) { }, function (err, body) {
if (!err) this.setState({'news': body}); if (!err) this.setState({'activity': body});
}.bind(this)); }.bind(this));
}, },
getActivity: function () { getFeaturedGlobal: function () {
this.api({ this.api({
uri: '/proxy/users/' + this.state.session.user.username + '/activity?limit=5' uri: '/proxy/featured'
}, function (err, body) { }, function (err, body) {
if (!err) this.setState({'activity': body}); if (!err) this.setState({featuredGlobal: body});
}.bind(this));
},
getFeaturedCustom: function () {
this.api({
uri: '/proxy/users/' + this.state.session.user.id + '/featured'
}, function (err, body) {
if (!err) this.setState({featuredCustom: body});
}.bind(this));
},
getNews: function () {
this.api({
uri: '/news?limit=3'
}, function (err, body) {
if (!err) this.setState({'news': body});
}.bind(this)); }.bind(this));
}, },
getProjectCount: function () { getProjectCount: function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment