Update local aliases checks to use stable API (#8698)
Fixes https://github.com/vector-im/element-web/issues/22337pull/28788/head^2
parent
8b17007795
commit
0f26ddd285
|
@ -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 });
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue