From ef67294f2ac0fc6040bbaf357ce35ca6f55c41e7 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 25 May 2022 11:08:27 -0600 Subject: [PATCH] Update local aliases checks to use stable API Fixes https://github.com/vector-im/element-web/issues/22337 --- .../views/room_settings/AliasSettings.tsx | 9 ++++----- .../settings/tabs/room/SecurityRoomSettingsTab.tsx | 13 +++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/components/views/room_settings/AliasSettings.tsx b/src/components/views/room_settings/AliasSettings.tsx index df1d57661bc..1a3e9bd417c 100644 --- a/src/components/views/room_settings/AliasSettings.tsx +++ b/src/components/views/room_settings/AliasSettings.tsx @@ -139,12 +139,11 @@ export default class AliasSettings extends React.Component { this.setState({ localAliasesLoading: true }); try { const mxClient = this.context; + let localAliases = []; - if (await mxClient.doesServerSupportUnstableFeature("org.matrix.msc2432")) { - const response = await mxClient.unstableGetLocalAliases(this.props.roomId); - if (Array.isArray(response.aliases)) { - localAliases = response.aliases; - } + const response = await mxClient.getLocalAliases(this.props.roomId); + if (Array.isArray(response?.aliases)) { + localAliases = response.aliases; } this.setState({ localAliases }); diff --git a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx index ba79cbd8759..6a72ec54412 100644 --- a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx +++ b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx @@ -220,16 +220,9 @@ export default class SecurityRoomSettingsTab extends React.Component { const cli = this.context; - if (await cli.doesServerSupportUnstableFeature("org.matrix.msc2432")) { - const response = await cli.unstableGetLocalAliases(this.props.roomId); - const localAliases = response.aliases; - return Array.isArray(localAliases) && localAliases.length !== 0; - } else { - const room = cli.getRoom(this.props.roomId); - const aliasEvents = room.currentState.getStateEvents(EventType.RoomAliases) || []; - const hasAliases = !!aliasEvents.find((ev) => (ev.getContent().aliases || []).length > 0); - return hasAliases; - } + const response = await cli.getLocalAliases(this.props.roomId); + const localAliases = response.aliases; + return Array.isArray(localAliases) && localAliases.length !== 0; } private renderJoinRule() {