From 867b47f4a21ccc26ed4f51b66e0f0763222b7682 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 27 Jun 2017 10:28:46 +0100 Subject: [PATCH] PR feedback: remove phases --- src/components/structures/GroupView.js | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 9140ee2c71..8a28a31001 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -30,21 +30,20 @@ module.exports = React.createClass({ getInitialState: function() { return { - phase: "GroupView.LOADING", // LOADING / DISPLAY / ERROR / NOT_FOUND summary: null, error: null, }; }, componentWillMount: function() { - this._loadGroupFromServer(this.props.groupId) + this._loadGroupFromServer(this.props.groupId); }, componentWillReceiveProps: function(new_props) { if (this.props.groupId != new_props.groupId) { this.setState({ - phase: "GroupView.LOADING", summary: null, + error: null, }) this._loadGroupFromServer(new_props.groupId); } @@ -53,12 +52,11 @@ module.exports = React.createClass({ _loadGroupFromServer: function(groupId) { MatrixClientPeg.get().getGroupSummary(groupId).done((res) => { this.setState({ - phase: "GroupView.DISPLAY", summary: res, + error: null, }); }, (err) => { this.setState({ - phase: err.httpStatus === 404 ? "GroupView.NOT_FOUND" : "GroupView.ERROR", summary: null, error: err, }); @@ -69,9 +67,9 @@ module.exports = React.createClass({ const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const Loader = sdk.getComponent("elements.Spinner"); - if (this.state.phase == "GroupView.LOADING") { + if (this.state.summary === null && this.state.error === null) { return ; - } else if (this.state.phase == "GroupView.DISPLAY") { + } else if (this.state.summary) { const summary = this.state.summary; let avatarUrl = null; if (summary.profile.avatarUrl) { @@ -109,23 +107,25 @@ module.exports = React.createClass({ {description} ); - } else if (this.state.phase == "GroupView.NOT_FOUND") { - return ( -
- Group {this.props.groupId} not found -
- ); - } else { - let extraText; - if (this.state.error.errcode === 'M_UNRECOGNIZED') { - extraText =
{_t('This Home server does not support groups')}
; + } else if (this.state.error) { + if (this.state.error.httpStatus === 404) { + return ( +
+ Group {this.props.groupId} not found +
+ ); + } else { + let extraText; + if (this.state.error.errcode === 'M_UNRECOGNIZED') { + extraText =
{_t('This Home server does not support groups')}
; + } + return ( +
+ Failed to load {this.props.groupId} + {extraText} +
+ ); } - return ( -
- Failed to load {this.props.groupId} - {extraText} -
- ); } }, });