Simplify event index store reset flow

This commit is contained in:
Germain Souquet 2021-03-29 15:46:58 +01:00
parent e53a8ad992
commit b38f5c9459
4 changed files with 14 additions and 22 deletions

View file

@ -36,8 +36,8 @@ export default class SeshatResetDialog extends React.PureComponent<IProps> {
<div>
<p>
{_t(
"Your event store appears corrupted. " +
"This action will restart this application.",
"Your event store appears to be corrupted. " +
"Your messages will be re-indexed as soon as the store is initialised.",
)}
</p>
</div>

View file

@ -123,11 +123,15 @@ export default class EventIndexPanel extends React.Component {
await this.updateState();
}
_confirmEventStoreReset() {
Modal.createDialog(SeshatResetDialog, {
onFinished: (success) => {
_confirmEventStoreReset = () => {
const self = this;
const { close } = Modal.createDialog(SeshatResetDialog, {
onFinished: async (success) => {
if (success) {
EventIndexPeg.resetEventStore();
await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false);
await EventIndexPeg.deleteEventIndex();
await self._onEnable();
close();
}
},
});
@ -223,7 +227,10 @@ export default class EventIndexPanel extends React.Component {
eventIndexingSettings = (
<div className='mx_SettingsTab_subsectionText'>
<p>
{_t("Message search initilisation failed")}
{this.state.enabling
? <InlineSpinner />
: _t("Message search initilisation failed")
}
</p>
{EventIndexPeg.error && (
<details>

View file

@ -309,14 +309,4 @@ export default abstract class BaseEventIndexManager {
async deleteEventIndex(): Promise<void> {
throw new Error("Unimplemented");
}
/**
* Reset a potentially corrupted event store
*
* @return {Promise} A promise that will resolve once the event store has
* been deleted.
*/
async resetEventStore(): Promise<void> {
throw new Error("Unimplemented");
}
}

View file

@ -179,11 +179,6 @@ class EventIndexPeg {
await indexManager.deleteEventIndex();
}
}
resetEventStore() {
const indexManager = PlatformPeg.get().getEventIndexingManager();
return indexManager.resetEventStore();
}
}
if (!global.mxEventIndexPeg) {