From f7cb633e3d004b60695f1757126529672f157daf Mon Sep 17 00:00:00 2001 From: Bruno Windels <brunow@matrix.org> Date: Mon, 9 Mar 2020 16:43:52 +0100 Subject: [PATCH] only load local aliases on mount when you can edit the canonical alias --- .../views/room_settings/AliasSettings.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/views/room_settings/AliasSettings.js b/src/components/views/room_settings/AliasSettings.js index d2a2c0e5f7..c6e4d1e3ba 100644 --- a/src/components/views/room_settings/AliasSettings.js +++ b/src/components/views/room_settings/AliasSettings.js @@ -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>