From 3baaaaab079257eed7ea8edf9faf4f77b8fc8d09 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 11 Mar 2020 12:03:16 +0100 Subject: [PATCH 1/2] use splice correctly after removing a local alias --- src/components/views/room_settings/AliasSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/room_settings/AliasSettings.js b/src/components/views/room_settings/AliasSettings.js index 0a7bd1d333..1d6b29c3ce 100644 --- a/src/components/views/room_settings/AliasSettings.js +++ b/src/components/views/room_settings/AliasSettings.js @@ -235,7 +235,7 @@ export default class AliasSettings extends React.Component { // to this room. See https://github.com/vector-im/riot-web/issues/7353 MatrixClientPeg.get().deleteAlias(alias).then(() => { const localAliases = this.state.localAliases.slice(); - localAliases.splice(index); + localAliases.splice(index, 1); this.setState({localAliases}); if (this.state.canonicalAlias === alias) { From cccf7cd07ff585f974c805aeab7f1a94cd85e86d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 11 Mar 2020 12:13:28 +0100 Subject: [PATCH 2/2] specific error for lack of permissions when trying to delete an alias --- .../views/room_settings/AliasSettings.js | 14 ++++++++++---- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/views/room_settings/AliasSettings.js b/src/components/views/room_settings/AliasSettings.js index 1d6b29c3ce..eab41c5ccd 100644 --- a/src/components/views/room_settings/AliasSettings.js +++ b/src/components/views/room_settings/AliasSettings.js @@ -243,12 +243,18 @@ export default class AliasSettings extends React.Component { } }).catch((err) => { console.error(err); - Modal.createTrackedDialog('Error removing alias', '', ErrorDialog, { - title: _t("Error removing alias"), - description: _t( + let description; + if (err.errcode === "M_FORBIDDEN") { + description = _t("You don't have permission to delete the alias."); + } else { + description = _t( "There was an error removing that alias. It may no longer exist or a temporary " + "error occurred.", - ), + ); + } + Modal.createTrackedDialog('Error removing alias', '', ErrorDialog, { + title: _t("Error removing alias"), + description, }); }); }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 10ae7fb455..d0e01917f3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1150,8 +1150,9 @@ "There was an error updating the room's alternative addresses. It may not be allowed by the server or a temporary failure occurred.": "There was an error updating the room's alternative addresses. It may not be allowed by the server or a temporary failure occurred.", "Error creating alias": "Error creating alias", "There was an error creating that alias. It may not be allowed by the server or a temporary failure occurred.": "There was an error creating that alias. It may not be allowed by the server or a temporary failure occurred.", - "Error removing alias": "Error removing alias", + "You don't have permission to delete the alias.": "You don't have permission to delete the alias.", "There was an error removing that alias. It may no longer exist or a temporary error occurred.": "There was an error removing that alias. It may no longer exist or a temporary error occurred.", + "Error removing alias": "Error removing alias", "Main address": "Main address", "not specified": "not specified", "This room has no local addresses": "This room has no local addresses",