diff --git a/src/autocomplete/UserProvider.js b/src/autocomplete/UserProvider.js index 35636c126c..26b30a3d27 100644 --- a/src/autocomplete/UserProvider.js +++ b/src/autocomplete/UserProvider.js @@ -112,7 +112,7 @@ export default class UserProvider extends AutocompleteProvider { } onUserSpoke(user: RoomMember) { - if (this.room === null) return; + if (this.users === null) return; if (user.userId === MatrixClientPeg.get().credentials.userId) return; // Move the user that spoke to the front of the array diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 6e135fcf7e..4f61bc4647 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -111,7 +111,11 @@ const CategoryRoomList = React.createClass({ ) :
; const roomNodes = this.props.rooms.map((r) => { - return ; + return ; }); let catHeader =
; @@ -131,6 +135,8 @@ const FeaturedRoom = React.createClass({ props: { summaryInfo: RoomSummaryType.isRequired, + editing: PropTypes.bool.isRequired, + groupId: PropTypes.string.isRequired, }, onClick: function(e) { @@ -144,6 +150,31 @@ const FeaturedRoom = React.createClass({ }); }, + onDeleteClicked: function(e) { + e.preventDefault(); + e.stopPropagation(); + MatrixClientPeg.get().removeRoomFromGroupSummary( + this.props.groupId, + this.props.summaryInfo.room_id, + ).catch((err) => { + console.error('Error whilst removing room from group summary', err); + const roomName = this.props.summaryInfo.name || + this.props.summaryInfo.canonical_alias || + this.props.summaryInfo.room_id; + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createTrackedDialog( + 'Failed to remove room from group summary', + '', ErrorDialog, + { + title: _t( + "Failed to remove the room from the summary of %(groupId)s", + {groupId: this.props.groupId}, + ), + description: _t("The room '%(roomName)s' could not be removed from the summary.", {roomName}), + }); + }); + }, + render: function() { const RoomAvatar = sdk.getComponent("avatars.RoomAvatar"); @@ -163,9 +194,20 @@ const FeaturedRoom = React.createClass({ roomNameNode = {this.props.summaryInfo.profile.name}; } + const deleteButton = this.props.editing ? + Delete + :
; + return
{roomNameNode}
+ {deleteButton}
; }, }); @@ -234,7 +276,11 @@ const RoleUserList = React.createClass({
) :
; const userNodes = this.props.users.map((u) => { - return ; + return ; }); let roleHeader =
; if (this.props.role && this.props.role.profile) { @@ -253,6 +299,8 @@ const FeaturedUser = React.createClass({ props: { summaryInfo: UserSummaryType.isRequired, + editing: PropTypes.bool.isRequired, + groupId: PropTypes.string.isRequired, }, onClick: function(e) { @@ -266,6 +314,29 @@ const FeaturedUser = React.createClass({ }); }, + onDeleteClicked: function(e) { + e.preventDefault(); + e.stopPropagation(); + MatrixClientPeg.get().removeUserFromGroupSummary( + this.props.groupId, + this.props.summaryInfo.user_id, + ).catch((err) => { + console.error('Error whilst removing user from group summary', err); + const displayName = this.props.summaryInfo.displayname || this.props.summaryInfo.user_id; + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createTrackedDialog( + 'Failed to remove user from group summary', + '', ErrorDialog, + { + title: _t( + "Failed to remove a user from the summary of %(groupId)s", + {groupId: this.props.groupId}, + ), + description: _t("The user '%(displayName)s' could not be removed from the summary.", {displayName}), + }); + }); + }, + render: function() { const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const name = this.props.summaryInfo.displayname || this.props.summaryInfo.user_id; @@ -275,9 +346,20 @@ const FeaturedUser = React.createClass({ const httpUrl = MatrixClientPeg.get() .mxcUrlToHttp(this.props.summaryInfo.avatar_url, 64, 64); + const deleteButton = this.props.editing ? + Delete + :
; + return
{userNameNode}
+ {deleteButton}
; }, }); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 1151035be7..a0945d7f50 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -875,5 +875,9 @@ "Add rooms to the group summary": "Add rooms to the group summary", "Which rooms would you like to add to this summary?": "Which rooms would you like to add to this summary?", "Room name or alias": "Room name or alias", - "You are an administrator of this group": "You are an administrator of this group" + "You are an administrator of this group": "You are an administrator of this group", + "Failed to remove the room from the summary of %(groupId)s": "Failed to remove the room from the summary of %(groupId)s", + "The room '%(roomName)' could not be removed from the summary.": "The room '%(roomName)' could not be removed from the summary.", + "Failed to remove a user from the summary of %(groupId)s": "Failed to remove a user from the summary of %(groupId)s", + "The user '%(displayName)s' could not be removed from the summary.": "The user '%(displayName)s' could not be removed from the summary." }