Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update local aliases checks to use stable API #8698

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/components/views/room_settings/AliasSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down