Update local aliases checks to use stable API (#8698)

Fixes https://github.com/vector-im/element-web/issues/22337
pull/28788/head^2
Travis Ralston 2022-05-25 15:56:30 -06:00 committed by GitHub
parent 8b17007795
commit 0f26ddd285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -139,12 +139,11 @@ export default class AliasSettings extends React.Component<IProps, IState> {
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 });

View File

@ -220,16 +220,9 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
private async hasAliases(): Promise<boolean> {
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() {