From 8879271a879f2e3d5f9eaf4f6612d870e48428a1 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Wed, 10 Nov 2021 14:08:19 +0100 Subject: [PATCH] Fix invalid validation for room aliases --- .../views/room_settings/AliasSettings.tsx | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/components/views/room_settings/AliasSettings.tsx b/src/components/views/room_settings/AliasSettings.tsx index d52e4b974282..66c04ed5b03c 100644 --- a/src/components/views/room_settings/AliasSettings.tsx +++ b/src/components/views/room_settings/AliasSettings.tsx @@ -206,20 +206,25 @@ export default class AliasSettings extends React.Component { eventContent["alt_aliases"] = altAliases; } - this.context.sendStateEvent(this.props.roomId, "m.room.canonical_alias", - this.context.mxClient.sendStateEvent(this.props.roomId, "m.room.canonical_alias", - eventContent, "").catch((err) => { - logger.error(err); - Modal.createTrackedDialog('Error updating alternative addresses', '', ErrorDialog, { - title: _t("Error updating main address"), - description: _t( - "There was an error updating the room's alternative addresses. " + + this.context.sendStateEvent(this.props.roomId, "m.room.canonical_alias", eventContent, "") + .then(() => { + this.setState({ + altAliases, + }); + }) + .catch((err) => { + // TODO: Add error handling based upon server validation + logger.error(err); + Modal.createTrackedDialog('Error updating alternative addresses', '', ErrorDialog, { + title: _t("Error updating main address"), + description: _t( + "There was an error updating the room's alternative addresses. " + "It may not be allowed by the server or a temporary failure occurred.", - ), + ), + }); + }).finally(() => { + this.setState({ updatingCanonicalAlias: false }); }); - }).finally(() => { - this.setState({ updatingCanonicalAlias: false }); - }); } private onNewAliasChanged = (value: string) => {