From 1c1bf82c2aa77756c16a4e5ca31b8e5daf5660a4 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 20 Sep 2017 16:32:02 +0100 Subject: [PATCH] Add users to group summary using new API --- src/components/structures/GroupView.js | 13 ++++--------- src/components/views/dialogs/UserPickerDialog.js | 9 ++++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index e7d7e145c3..f5ee35c1ea 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -133,13 +133,6 @@ const RoleUserList = React.createClass({ groupId: PropTypes.string.isRequired, }, - onUsersSelected: function(addrs) { - addrs.forEach((addr) => { - // const userId = addr.address; - // TODO: Add user to the group via API hit - }); - }, - onAddUsersClicked: function(ev) { ev.preventDefault(); const UserPickerDialog = sdk.getComponent("dialogs.UserPickerDialog"); @@ -152,8 +145,10 @@ const RoleUserList = React.createClass({ groupId: this.props.groupId, onFinished: (success, addrs) => { if (!success) return; - - this.onUsersSelected(addrs); + addrs.map((addr) => { + return MatrixClientPeg.get() + .addUserToGroupSummary(this.props.groupId, addr.address); + }); }, }); }, diff --git a/src/components/views/dialogs/UserPickerDialog.js b/src/components/views/dialogs/UserPickerDialog.js index 2bd2320b21..718780ace4 100644 --- a/src/components/views/dialogs/UserPickerDialog.js +++ b/src/components/views/dialogs/UserPickerDialog.js @@ -195,7 +195,14 @@ module.exports = React.createClass({ searchError: null, }); MatrixClientPeg.get().getGroupUsers(this.props.groupId).then((resp) => { - this._processResults(resp.chunk, query); + const results = resp.chunk.map((u) => { + return { + user_id: u.user_id, + avatar_url: u.avatar_url, + display_name: u.displayname, + }; + }); + this._processResults(results, query); }).catch((err) => { console.error('Error whilst searching user directory: ', err); this.setState({