From 4d9c43b3c8c9cad85548fc0dd4002f2c568f8fd3 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 21 Sep 2017 12:34:16 +0100 Subject: [PATCH] Display dialog when errors occur whilst featuring users --- src/components/structures/GroupView.js | 23 +++++++++++++++++++++-- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 57bce7cba9..7d64820c5e 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -17,6 +17,7 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; +import Promise from 'bluebird'; import MatrixClientPeg from '../../MatrixClientPeg'; import sdk from '../../index'; import dis from '../../dispatcher'; @@ -149,9 +150,27 @@ const RoleUserList = React.createClass({ groupId: this.props.groupId, onFinished: (success, addrs) => { if (!success) return; - addrs.map((addr) => { + const errorList = []; + Promise.all(addrs.map((addr) => { return MatrixClientPeg.get() - .addUserToGroupSummary(this.props.groupId, addr.address); + .addUserToGroupSummary(this.props.groupId, addr.address) + .catch(() => { errorList.push(addr.address); }) + .reflect(); + })).then(() => { + if (errorList.length === 0) { + return; + } + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createTrackedDialog( + 'Failed to add the following users to the group summary', + '', ErrorDialog, + { + title: _t( + "Failed to add the following users to the summary of %(groupId)s:", + {groupId: this.props.groupId}, + ), + description: errorList.join(", "), + }); }); }, }); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8c8c2e4ac0..d759547e66 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -891,5 +891,6 @@ "Add a User": "Add a User", "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" + "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:" }