show spinner while loading local aliases

This commit is contained in:
Bruno Windels 2020-02-19 15:15:05 +01:00
parent 7f71e551da
commit a5b9682572

View File

@ -91,6 +91,7 @@ export default class AliasSettings extends React.Component {
remoteDomains: [], // [ domain.com, foobar.com ] remoteDomains: [], // [ domain.com, foobar.com ]
canonicalAlias: null, // #canonical:domain.com canonicalAlias: null, // #canonical:domain.com
updatingCanonicalAlias: false, updatingCanonicalAlias: false,
localAliasesLoading: true,
}; };
if (props.canonicalAliasEvent) { if (props.canonicalAliasEvent) {
@ -102,6 +103,7 @@ export default class AliasSettings extends React.Component {
async componentWillMount() { async componentWillMount() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
try {
if (await cli.doesServerSupportUnstableFeature("org.matrix.msc2432")) { if (await cli.doesServerSupportUnstableFeature("org.matrix.msc2432")) {
const response = await cli.unstableGetLocalAliases(this.props.roomId); const response = await cli.unstableGetLocalAliases(this.props.roomId);
const localAliases = response.aliases; const localAliases = response.aliases;
@ -125,6 +127,9 @@ export default class AliasSettings extends React.Component {
}); });
this.setState(state); this.setState(state);
} }
} finally {
this.setState({localAliasesLoading: false});
}
} }
aliasesToDictionary(aliases) { aliasesToDictionary(aliases) {
@ -302,10 +307,12 @@ export default class AliasSettings extends React.Component {
); );
} }
return ( let localAliasesList;
<div className='mx_AliasSettings'> if (this.state.localAliasesLoading) {
{canonicalAliasSection} const Spinner = sdk.getComponent("elements.Spinner");
<EditableAliasesList localAliasesList = <Spinner />;
} else {
localAliasesList = <EditableAliasesList
id="roomAliases" id="roomAliases"
className={"mx_RoomSettings_localAliases"} className={"mx_RoomSettings_localAliases"}
items={this.state.domainToAliases[localDomain] || []} items={this.state.domainToAliases[localDomain] || []}
@ -321,7 +328,13 @@ export default class AliasSettings extends React.Component {
'New address (e.g. #foo:%(localDomain)s)', {localDomain: localDomain}, 'New address (e.g. #foo:%(localDomain)s)', {localDomain: localDomain},
)} )}
domain={localDomain} domain={localDomain}
/> />;
}
return (
<div className='mx_AliasSettings'>
{canonicalAliasSection}
{localAliasesList}
{remoteAliasesSection} {remoteAliasesSection}
</div> </div>
); );