From d4f5e7e6d71fbc84e8a95220328aef0249114b58 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 28 Nov 2017 10:46:20 +0000 Subject: [PATCH] Deal with errors, lack of groups, loading --- .../views/groups/GroupUserSettings.js | 49 ++++++++++++++----- src/i18n/strings/en_EN.json | 5 +- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/components/views/groups/GroupUserSettings.js b/src/components/views/groups/GroupUserSettings.js index 4d72c96a1f..755d6aae8f 100644 --- a/src/components/views/groups/GroupUserSettings.js +++ b/src/components/views/groups/GroupUserSettings.js @@ -30,37 +30,60 @@ export default React.createClass({ getInitialState() { return { - err: null, + error: null, groups: null, }; }, componentWillMount: function() { this.context.matrixClient.getJoinedGroups().done((result) => { - this.setState({groups: result.groups, error: null}); + this.setState({groups: result.groups || [], error: null}); }, (err) => { console.error(err); this.setState({groups: null, error: err}); }); }, - render() { - const GroupPublicityToggle = sdk.getComponent('groups.GroupPublicityToggle'); - const groupPublicityToggles = (this.state.groups || []).map((groupId, index) => { - return ; - }); + _renderGroupPublicity() { + let text = ""; + let scrollbox =
; + const groups = this.state.groups; + + if (this.state.error) { + text = _t('Something went wrong when trying to get your communities.'); + } else if (groups === null) { + text = _t('Loading...'); + } else if (groups.length > 0) { + const GroupPublicityToggle = sdk.getComponent('groups.GroupPublicityToggle'); + const groupPublicityToggles = groups.map((groupId, index) => { + return ; + }); + text = _t('Display your community flair in rooms configured to show it.'); + scrollbox =
+ + { groupPublicityToggles } + +
; + } else { + text = _t("You're not currently a member of any communities."); + } + return

{ _t('Flair') }

- { _t('Display your community flair in rooms configured to show it.') } + { text }

-
- - { groupPublicityToggles } - -
+ { scrollbox }
; }, + + render() { + const groupPublicity = this._renderGroupPublicity(); + + return
+ { groupPublicity } +
; + }, }); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index cf108b3a6e..b07fabbacf 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -530,8 +530,10 @@ "Visible to everyone": "Visible to everyone", "Only visible to community members": "Only visible to community members", "Filter community rooms": "Filter community rooms", - "Flair": "Flair", + "Something went wrong when trying to get your communities.": "Something went wrong when trying to get your communities.", "Display your community flair in rooms configured to show it.": "Display your community flair in rooms configured to show it.", + "You're not currently a member of any communities.": "You're not currently a member of any communities.", + "Flair": "Flair", "Unknown Address": "Unknown Address", "NOTE: Apps are not end-to-end encrypted": "NOTE: Apps are not end-to-end encrypted", "Do you want to load widget from URL:": "Do you want to load widget from URL:", @@ -742,7 +744,6 @@ "For security, this session has been signed out. Please sign in again.": "For security, this session has been signed out. Please sign in again.", "Logout": "Logout", "Your Communities": "Your Communities", - "You're not currently a member of any communities.": "You're not currently a member of any communities.", "Error whilst fetching joined communities": "Error whilst fetching joined communities", "Create a new community": "Create a new community", "Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.": "Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.",