DisableEventIndex: Set the correct button kind and add a spinner.

pull/21833/head
Damir Jelić 2020-01-23 15:05:40 +01:00
parent 981acec0d2
commit 3073ce5588
1 changed files with 14 additions and 8 deletions

View File

@ -41,12 +41,15 @@ export default class ManageEventIndex extends React.Component {
super(props); super(props);
this.state = { this.state = {
eventIndexingEnabled: disabling: false,
SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableEventIndexing'),
}; };
} }
_onDisable = async () => { _onDisable = async () => {
this.setState({
disabling: true,
});
const eventIndex = EventIndexPeg.get(); const eventIndex = EventIndexPeg.get();
await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false); await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false);
await EventIndexPeg.deleteEventIndex(); await EventIndexPeg.deleteEventIndex();
@ -64,12 +67,15 @@ export default class ManageEventIndex extends React.Component {
title={_t("Are you sure?")} title={_t("Are you sure?")}
> >
{_t("If disabled, messages form encrypted rooms won't appear in search results")} {_t("If disabled, messages form encrypted rooms won't appear in search results")}
<DialogButtons <div className="mx_Dialog_buttons">
primaryButton={_t("Disable")} <AccessibleButton kind="secondary" onClick={this.props.onFinished}>
onPrimaryButtonClick={this._onDisable} {_t("Cancel")}
cancelButton={_t("Cancel")} </AccessibleButton>
onCancel={this.props.onFinished} <AccessibleButton kind="danger" disabled={this.state.disabling} onClick={this._onDisable}>
/> {_t("Disable")}
</AccessibleButton>
{this.state.enabling ? <InlineSpinner /> : <div />}
</div>
</BaseDialog> </BaseDialog>
); );
} }