diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 3d29c6d607..8b07db4962 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -547,9 +547,20 @@ export default React.createClass({ ; } else if (group.myMembership === 'join') { + let youAreAMemberText = _t("You are a member of this group"); + if (this.state.summary.user && this.state.summary.user.is_privileged) { + youAreAMemberText = _t("You are an administrator of this group"); + } return
- {_t("You are a member of this group")} + {youAreAMemberText} +
+
+ + {_t("Leave")} +
; - rightButtons.push( - - - , - ); + if (summary.user && summary.user.is_privileged) { + rightButtons.push( + + + , + ); + } if (this.props.collapsedRhs) { rightButtons.push( ; + } +} + +FlairAvatar.propTypes = { + groupProfile: PropTypes.shape({ + groupId: PropTypes.string.isRequired, + avatarUrl: PropTypes.string.isRequired, + }), +}; + +FlairAvatar.contextTypes = { + matrixClient: React.PropTypes.instanceOf(MatrixClient).isRequired, +}; + export default class Flair extends React.Component { constructor() { super(); this.state = { - avatarUrls: [], + profiles: [], }; } @@ -143,7 +183,7 @@ export default class Flair extends React.Component { } } - async _getAvatarUrls(groups) { + async _getGroupProfiles(groups) { const profiles = []; for (const groupId of groups) { let groupProfile = null; @@ -154,9 +194,7 @@ export default class Flair extends React.Component { } profiles.push(groupProfile); } - - const avatarUrls = profiles.filter((p) => p !== null).map((p) => p.avatar_url); - return avatarUrls; + return profiles.filter((p) => p !== null); } async _generateAvatars() { @@ -176,19 +214,18 @@ export default class Flair extends React.Component { if (!groups || groups.length === 0) { return; } - const avatarUrls = await this._getAvatarUrls(groups); + const profiles = await this._getGroupProfiles(groups); if (!this.unmounted) { - this.setState({avatarUrls}); + this.setState({profiles}); } } render() { - if (this.state.avatarUrls.length === 0) { + if (this.state.profiles.length === 0) { return
; } - const avatars = this.state.avatarUrls.map((avatarUrl, index) => { - const httpUrl = this.context.matrixClient.mxcUrlToHttp(avatarUrl, 14, 14, 'scale', false); - return ; + const avatars = this.state.profiles.map((profile, index) => { + return ; }); return ( diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index ac0d3e047c..a6d34f9b08 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -89,6 +89,7 @@ module.exports = React.createClass({ cli.on("RoomMember.name", this.onRoomMemberName); cli.on("Event.decrypted", this.onEventDecrypted); cli.on("accountData", this.onAccountData); + cli.on("Group.myMembership", this._onGroupMyMembership); this.refreshRoomList(); @@ -157,6 +158,7 @@ module.exports = React.createClass({ MatrixClientPeg.get().removeListener("RoomMember.name", this.onRoomMemberName); MatrixClientPeg.get().removeListener("Event.decrypted", this.onEventDecrypted); MatrixClientPeg.get().removeListener("accountData", this.onAccountData); + MatrixClientPeg.get().removeListener("Group.myMembership", this._onGroupMyMembership); } // cancel any pending calls to the rate_limited_funcs this._delayedRefreshRoomList.cancelPendingCall(); @@ -236,6 +238,10 @@ module.exports = React.createClass({ } }, + _onGroupMyMembership: function(group) { + this.forceUpdate(); + }, + _delayedRefreshRoomList: new rate_limited_func(function() { this.refreshRoomList(); }, 500), diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index d759547e66..0ff1b9bc84 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -892,5 +892,6 @@ "Add users to the group summary": "Add users to the group summary", "Who would you like to add to this summary?": "Who would you like to add to this summary?", "Add to summary": "Add to summary", - "Failed to add the following users to the summary of %(groupId)s:": "Failed to add the following users to the summary of %(groupId)s:" + "Failed to add the following users to the summary of %(groupId)s:": "Failed to add the following users to the summary of %(groupId)s:", + "You are an administrator of this group": "You are an administrator of this group" }