mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
only load local aliases on mount when you can edit the canonical alias
This commit is contained in:
parent
053ba1110a
commit
f7cb633e3d
1 changed files with 16 additions and 2 deletions
|
@ -112,7 +112,11 @@ export default class AliasSettings extends React.Component {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
return this.loadLocalAliases();
|
||||
if (this.props.canSetCanonicalAlias) {
|
||||
// load local aliases for providing recommendations
|
||||
// for the canonical alias and alt_aliases
|
||||
this.loadLocalAliases();
|
||||
}
|
||||
}
|
||||
|
||||
async loadLocalAliases() {
|
||||
|
@ -249,6 +253,16 @@ export default class AliasSettings extends React.Component {
|
|||
});
|
||||
};
|
||||
|
||||
onLocalAliasesToggled = (event) => {
|
||||
// expanded
|
||||
if (event.target.open) {
|
||||
// if local aliases haven't been preloaded yet at component mount
|
||||
if (!this.props.canSetCanonicalAlias && this.state.localAliases.length === 0) {
|
||||
this.loadLocalAliases();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onCanonicalAliasChange = (event) => {
|
||||
this.changeCanonicalAlias(event.target.value);
|
||||
};
|
||||
|
@ -358,7 +372,7 @@ export default class AliasSettings extends React.Component {
|
|||
'New address (e.g. #foo:domain)',
|
||||
)}
|
||||
/>
|
||||
<details>
|
||||
<details onToggle={this.onLocalAliasesToggled}>
|
||||
<summary>{_t('Local addresses (unmoderated content)')}</summary>
|
||||
{localAliasesList}
|
||||
</details>
|
||||
|
|
Loading…
Reference in a new issue