mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 14:05:04 +08:00
show spinner while loading local aliases
This commit is contained in:
parent
7f71e551da
commit
a5b9682572
@ -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,28 +103,32 @@ export default class AliasSettings extends React.Component {
|
|||||||
|
|
||||||
async componentWillMount() {
|
async componentWillMount() {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (await cli.doesServerSupportUnstableFeature("org.matrix.msc2432")) {
|
try {
|
||||||
const response = await cli.unstableGetLocalAliases(this.props.roomId);
|
if (await cli.doesServerSupportUnstableFeature("org.matrix.msc2432")) {
|
||||||
const localAliases = response.aliases;
|
const response = await cli.unstableGetLocalAliases(this.props.roomId);
|
||||||
const localDomain = cli.getDomain();
|
const localAliases = response.aliases;
|
||||||
const domainToAliases = Object.assign(
|
const localDomain = cli.getDomain();
|
||||||
{},
|
const domainToAliases = Object.assign(
|
||||||
// FIXME, any localhost alt_aliases will be ignored as they are overwritten by localAliases
|
{},
|
||||||
this.aliasesToDictionary(this._getAltAliases()),
|
// FIXME, any localhost alt_aliases will be ignored as they are overwritten by localAliases
|
||||||
{[localDomain]: localAliases || []},
|
this.aliasesToDictionary(this._getAltAliases()),
|
||||||
);
|
{[localDomain]: localAliases || []},
|
||||||
const remoteDomains = Object.keys(domainToAliases).filter((domain) => {
|
);
|
||||||
return domain !== localDomain && domainToAliases[domain].length > 0;
|
const remoteDomains = Object.keys(domainToAliases).filter((domain) => {
|
||||||
});
|
return domain !== localDomain && domainToAliases[domain].length > 0;
|
||||||
this.setState({ domainToAliases, remoteDomains });
|
});
|
||||||
} else {
|
this.setState({ domainToAliases, remoteDomains });
|
||||||
const state = {};
|
} else {
|
||||||
const localDomain = cli.getDomain();
|
const state = {};
|
||||||
state.domainToAliases = this.aliasEventsToDictionary(this.props.aliasEvents || []);
|
const localDomain = cli.getDomain();
|
||||||
state.remoteDomains = Object.keys(state.domainToAliases).filter((domain) => {
|
state.domainToAliases = this.aliasEventsToDictionary(this.props.aliasEvents || []);
|
||||||
return domain !== localDomain && state.domainToAliases[domain].length > 0;
|
state.remoteDomains = Object.keys(state.domainToAliases).filter((domain) => {
|
||||||
});
|
return domain !== localDomain && state.domainToAliases[domain].length > 0;
|
||||||
this.setState(state);
|
});
|
||||||
|
this.setState(state);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.setState({localAliasesLoading: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,26 +307,34 @@ export default class AliasSettings extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let localAliasesList;
|
||||||
|
if (this.state.localAliasesLoading) {
|
||||||
|
const Spinner = sdk.getComponent("elements.Spinner");
|
||||||
|
localAliasesList = <Spinner />;
|
||||||
|
} else {
|
||||||
|
localAliasesList = <EditableAliasesList
|
||||||
|
id="roomAliases"
|
||||||
|
className={"mx_RoomSettings_localAliases"}
|
||||||
|
items={this.state.domainToAliases[localDomain] || []}
|
||||||
|
newItem={this.state.newAlias}
|
||||||
|
onNewItemChanged={this.onNewAliasChanged}
|
||||||
|
canRemove={this.props.canSetAliases}
|
||||||
|
canEdit={this.props.canSetAliases}
|
||||||
|
onItemAdded={this.onLocalAliasAdded}
|
||||||
|
onItemRemoved={this.onLocalAliasDeleted}
|
||||||
|
itemsLabel={_t('Local addresses for this room:')}
|
||||||
|
noItemsLabel={_t('This room has no local addresses')}
|
||||||
|
placeholder={_t(
|
||||||
|
'New address (e.g. #foo:%(localDomain)s)', {localDomain: localDomain},
|
||||||
|
)}
|
||||||
|
domain={localDomain}
|
||||||
|
/>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='mx_AliasSettings'>
|
<div className='mx_AliasSettings'>
|
||||||
{canonicalAliasSection}
|
{canonicalAliasSection}
|
||||||
<EditableAliasesList
|
{localAliasesList}
|
||||||
id="roomAliases"
|
|
||||||
className={"mx_RoomSettings_localAliases"}
|
|
||||||
items={this.state.domainToAliases[localDomain] || []}
|
|
||||||
newItem={this.state.newAlias}
|
|
||||||
onNewItemChanged={this.onNewAliasChanged}
|
|
||||||
canRemove={this.props.canSetAliases}
|
|
||||||
canEdit={this.props.canSetAliases}
|
|
||||||
onItemAdded={this.onLocalAliasAdded}
|
|
||||||
onItemRemoved={this.onLocalAliasDeleted}
|
|
||||||
itemsLabel={_t('Local addresses for this room:')}
|
|
||||||
noItemsLabel={_t('This room has no local addresses')}
|
|
||||||
placeholder={_t(
|
|
||||||
'New address (e.g. #foo:%(localDomain)s)', {localDomain: localDomain},
|
|
||||||
)}
|
|
||||||
domain={localDomain}
|
|
||||||
/>
|
|
||||||
{remoteAliasesSection}
|
{remoteAliasesSection}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user