Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5ac1d3a

Browse files
authored
Merge pull request #5806 from matrix-org/gsouquet-seshat-reset
2 parents 2ab3041 + a434581 commit 5ac1d3a

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Copyright 2021 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import {_t} from "../../../languageHandler";
19+
import {replaceableComponent} from "../../../utils/replaceableComponent";
20+
21+
import BaseDialog from "./BaseDialog";
22+
import DialogButtons from "../elements/DialogButtons";
23+
24+
import {IDialogProps} from "./IDialogProps";
25+
26+
@replaceableComponent("views.dialogs.SeshatResetDialog")
27+
export default class SeshatResetDialog extends React.PureComponent<IDialogProps> {
28+
render() {
29+
return (
30+
<BaseDialog
31+
hasCancel={true}
32+
onFinished={this.props.onFinished.bind(null, false)}
33+
title={_t("Reset event store?")}>
34+
<div>
35+
<p>
36+
{_t("You most likely do not want to reset your event index store")}
37+
<br />
38+
{_t("If you do, please note that none of your messages will be deleted, " +
39+
"but the search experience might be degraded for a few moments" +
40+
"whilst the index is recreated",
41+
)}
42+
</p>
43+
</div>
44+
<DialogButtons
45+
primaryButton={_t("Reset event store")}
46+
onPrimaryButtonClick={this.props.onFinished.bind(null, true)}
47+
primaryButtonClass="danger"
48+
cancelButton={_t("Cancel")}
49+
onCancel={this.props.onFinished.bind(null, false)}
50+
/>
51+
</BaseDialog>
52+
);
53+
}
54+
}

src/components/views/settings/EventIndexPanel.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {formatBytes, formatCountLong} from "../../../utils/FormattingUtils";
2626
import EventIndexPeg from "../../../indexing/EventIndexPeg";
2727
import {SettingLevel} from "../../../settings/SettingLevel";
2828
import {replaceableComponent} from "../../../utils/replaceableComponent";
29+
import SeshatResetDialog from '../dialogs/SeshatResetDialog';
2930

3031
@replaceableComponent("views.settings.EventIndexPanel")
3132
export default class EventIndexPanel extends React.Component {
@@ -122,6 +123,20 @@ export default class EventIndexPanel extends React.Component {
122123
await this.updateState();
123124
}
124125

126+
_confirmEventStoreReset = () => {
127+
const self = this;
128+
const { close } = Modal.createDialog(SeshatResetDialog, {
129+
onFinished: async (success) => {
130+
if (success) {
131+
await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false);
132+
await EventIndexPeg.deleteEventIndex();
133+
await self._onEnable();
134+
close();
135+
}
136+
},
137+
});
138+
}
139+
125140
render() {
126141
let eventIndexingSettings = null;
127142
const InlineSpinner = sdk.getComponent('elements.InlineSpinner');
@@ -212,14 +227,22 @@ export default class EventIndexPanel extends React.Component {
212227
eventIndexingSettings = (
213228
<div className='mx_SettingsTab_subsectionText'>
214229
<p>
215-
{_t("Message search initialisation failed")}
230+
{this.state.enabling
231+
? <InlineSpinner />
232+
: _t("Message search initilisation failed")
233+
}
216234
</p>
217235
{EventIndexPeg.error && (
218236
<details>
219237
<summary>{_t("Advanced")}</summary>
220238
<code>
221239
{EventIndexPeg.error.message}
222240
</code>
241+
<p>
242+
<AccessibleButton key="delete" kind="danger" onClick={this._confirmEventStoreReset}>
243+
{_t("Reset")}
244+
</AccessibleButton>
245+
</p>
223246
</details>
224247
)}
225248

src/i18n/strings/en_EN.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@
10841084
"Securely cache encrypted messages locally for them to appear in search results.": "Securely cache encrypted messages locally for them to appear in search results.",
10851085
"%(brand)s is missing some components required for securely caching encrypted messages locally. If you'd like to experiment with this feature, build a custom %(brand)s Desktop with <nativeLink>search components added</nativeLink>.": "%(brand)s is missing some components required for securely caching encrypted messages locally. If you'd like to experiment with this feature, build a custom %(brand)s Desktop with <nativeLink>search components added</nativeLink>.",
10861086
"%(brand)s can't securely cache encrypted messages locally while running in a web browser. Use <desktopLink>%(brand)s Desktop</desktopLink> for encrypted messages to appear in search results.": "%(brand)s can't securely cache encrypted messages locally while running in a web browser. Use <desktopLink>%(brand)s Desktop</desktopLink> for encrypted messages to appear in search results.",
1087-
"Message search initialisation failed": "Message search initialisation failed",
1087+
"Message search initilisation failed": "Message search initilisation failed",
10881088
"Connecting to integration manager...": "Connecting to integration manager...",
10891089
"Cannot connect to integration manager": "Cannot connect to integration manager",
10901090
"The integration manager is offline or it cannot reach your homeserver.": "The integration manager is offline or it cannot reach your homeserver.",
@@ -2305,6 +2305,10 @@
23052305
"Use your preferred Matrix homeserver if you have one, or host your own.": "Use your preferred Matrix homeserver if you have one, or host your own.",
23062306
"Learn more": "Learn more",
23072307
"About homeservers": "About homeservers",
2308+
"Reset event store?": "Reset event store?",
2309+
"You most likely do not want to reset your event index store": "You most likely do not want to reset your event index store",
2310+
"If you do, please note that none of your messages will be deleted, but the search experience might be degraded for a few momentswhilst the index is recreated": "If you do, please note that none of your messages will be deleted, but the search experience might be degraded for a few momentswhilst the index is recreated",
2311+
"Reset event store": "Reset event store",
23082312
"Sign out and remove encryption keys?": "Sign out and remove encryption keys?",
23092313
"Clear Storage and Sign Out": "Clear Storage and Sign Out",
23102314
"Send Logs": "Send Logs",

0 commit comments

Comments
 (0)