mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-01 11:03:18 +03:00
EventIndexPanel: Add a spinner when the index is being enabled.
This commit is contained in:
parent
251661388a
commit
a5a149933a
1 changed files with 17 additions and 5 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
import * as sdk from '../../../index';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||||
import AccessibleButton from "../elements/AccessibleButton";
|
import AccessibleButton from "../elements/AccessibleButton";
|
||||||
|
@ -28,6 +29,7 @@ export default class EventIndexPanel extends React.Component {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
enabling: false,
|
||||||
eventIndexSize: 0,
|
eventIndexSize: 0,
|
||||||
roomCount: 0,
|
roomCount: 0,
|
||||||
eventIndexingEnabled:
|
eventIndexingEnabled:
|
||||||
|
@ -58,11 +60,12 @@ export default class EventIndexPanel extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateState() {
|
async updateState() {
|
||||||
let eventIndexSize = 0;
|
|
||||||
let roomCount = 0;
|
|
||||||
|
|
||||||
const eventIndex = EventIndexPeg.get();
|
const eventIndex = EventIndexPeg.get();
|
||||||
const eventIndexingEnabled = SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableEventIndexing');
|
const eventIndexingEnabled = SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableEventIndexing');
|
||||||
|
const enabling = false;
|
||||||
|
|
||||||
|
let eventIndexSize = 0;
|
||||||
|
let roomCount = 0;
|
||||||
|
|
||||||
if (eventIndex !== null) {
|
if (eventIndex !== null) {
|
||||||
eventIndex.on("changedCheckpoint", this.updateCurrentRoom.bind(this));
|
eventIndex.on("changedCheckpoint", this.updateCurrentRoom.bind(this));
|
||||||
|
@ -73,6 +76,7 @@ export default class EventIndexPanel extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
enabling,
|
||||||
eventIndexSize,
|
eventIndexSize,
|
||||||
roomCount,
|
roomCount,
|
||||||
eventIndexingEnabled,
|
eventIndexingEnabled,
|
||||||
|
@ -89,6 +93,10 @@ export default class EventIndexPanel extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onEnable = async () => {
|
_onEnable = async () => {
|
||||||
|
this.setState({
|
||||||
|
enabling: true,
|
||||||
|
});
|
||||||
|
|
||||||
await EventIndexPeg.initEventIndex();
|
await EventIndexPeg.initEventIndex();
|
||||||
await EventIndexPeg.get().addInitialCheckpoints();
|
await EventIndexPeg.get().addInitialCheckpoints();
|
||||||
await EventIndexPeg.get().startCrawler();
|
await EventIndexPeg.get().startCrawler();
|
||||||
|
@ -98,6 +106,7 @@ export default class EventIndexPanel extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let eventIndexingSettings = null;
|
let eventIndexingSettings = null;
|
||||||
|
const InlineSpinner = sdk.getComponent('elements.InlineSpinner');
|
||||||
|
|
||||||
if (EventIndexPeg.get() !== null) {
|
if (EventIndexPeg.get() !== null) {
|
||||||
eventIndexingSettings = (
|
eventIndexingSettings = (
|
||||||
|
@ -119,12 +128,15 @@ export default class EventIndexPanel extends React.Component {
|
||||||
eventIndexingSettings = (
|
eventIndexingSettings = (
|
||||||
<div>
|
<div>
|
||||||
<div className='mx_SettingsTab_subsectionText'>
|
<div className='mx_SettingsTab_subsectionText'>
|
||||||
{_t( "Securely cache encrypted messages locally for them to appear in search results.")}
|
{_t( "Securely cache encrypted messages locally for them to " +
|
||||||
|
"appear in search results.")}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<AccessibleButton kind="primary" onClick={this._onEnable}>
|
<AccessibleButton kind="primary" disabled={this.state.enabling}
|
||||||
|
onClick={this._onEnable}>
|
||||||
{_t("Enable")}
|
{_t("Enable")}
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
|
{this.state.enabling ? <InlineSpinner /> : <div />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue