From 64c4ad2eb9474dbacd681954682f677fb97d71cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 23 Jan 2020 13:33:55 +0100 Subject: [PATCH] ManageEventIndex: Hook up the disable event index button. --- .../dialogs/eventindex/DisableEventIndex.js | 74 +++++++++++++++++++ .../dialogs/eventindex/ManageEventIndex.js | 6 +- src/i18n/strings/en_EN.json | 8 +- 3 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 src/async-components/views/dialogs/eventindex/DisableEventIndex.js diff --git a/src/async-components/views/dialogs/eventindex/DisableEventIndex.js b/src/async-components/views/dialogs/eventindex/DisableEventIndex.js new file mode 100644 index 0000000000..159f8b3d95 --- /dev/null +++ b/src/async-components/views/dialogs/eventindex/DisableEventIndex.js @@ -0,0 +1,74 @@ +/* +Copyright 2020 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React from 'react'; +import * as sdk from '../../../../index'; +import PropTypes from 'prop-types'; +import { _t } from '../../../../languageHandler'; + +import SettingsStore, {SettingLevel} from "../../../../settings/SettingsStore"; +import LabelledToggleSwitch from "../../../../components/views/elements/LabelledToggleSwitch"; +import Field from "../../../../components/views/elements/Field"; +import {formatBytes} from "../../../../utils/FormattingUtils"; +import EventIndexPeg from "../../../../indexing/EventIndexPeg"; +import AccessibleButton from "../../../../components/views/elements/AccessibleButton"; + + +/* + * Walks the user through the process of creating an e2e key backup + * on the server. + */ +export default class ManageEventIndex extends React.Component { + static propTypes = { + onFinished: PropTypes.func.isRequired, + } + + constructor(props) { + super(props); + + this.state = { + eventIndexingEnabled: + SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableEventIndexing'), + }; + } + + _onDisable = async () => { + const eventIndex = EventIndexPeg.get(); + await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, false); + await EventIndexPeg.deleteEventIndex(); + this.props.onFinished(true); + } + + render() { + const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); + const DialogButtons = sdk.getComponent("views.elements.DialogButtons"); + + return ( + + {_t("If disabled, messages form encrypted rooms won't appear in search results")} + + + ); + } +} diff --git a/src/async-components/views/dialogs/eventindex/ManageEventIndex.js b/src/async-components/views/dialogs/eventindex/ManageEventIndex.js index be7df25381..cf0e2bccc6 100644 --- a/src/async-components/views/dialogs/eventindex/ManageEventIndex.js +++ b/src/async-components/views/dialogs/eventindex/ManageEventIndex.js @@ -19,6 +19,7 @@ import * as sdk from '../../../../index'; import PropTypes from 'prop-types'; import { _t } from '../../../../languageHandler'; +import Modal from '../../../../Modal'; import SettingsStore, {SettingLevel} from "../../../../settings/SettingsStore"; import LabelledToggleSwitch from "../../../../components/views/elements/LabelledToggleSwitch"; import Field from "../../../../components/views/elements/Field"; @@ -101,7 +102,10 @@ export default class ManageEventIndex extends React.Component { } _onDisable = async () => { - this.props.onFinished(false); + Modal.createTrackedDialogAsync("Disable message search", "Disable message search", + import("./DisableEventIndex"), + null, null, /* priority = */ false, /* static = */ true, + ); } _onEnable = async () => { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b2ac55ba04..31ba5581f3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -416,6 +416,7 @@ "Send read receipts for messages (requires compatible homeserver to disable)": "Send read receipts for messages (requires compatible homeserver to disable)", "Show previews/thumbnails for images": "Show previews/thumbnails for images", "How long should the crawler wait between requests": "How long should the crawler wait between requests", + "Enable message search in encrypted rooms": "Enable message search in encrypted rooms", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading report": "Uploading report", @@ -2035,6 +2036,8 @@ "This device has detected that your recovery passphrase and key for Secure Messages have been removed.": "This device has detected that your recovery passphrase and key for Secure Messages have been removed.", "If you did this accidentally, you can setup Secure Messages on this device which will re-encrypt this device's message history with a new recovery method.": "If you did this accidentally, you can setup Secure Messages on this device which will re-encrypt this device's message history with a new recovery method.", "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.": "If you didn't remove the recovery method, an attacker may be trying to access your account. Change your account password and set a new recovery method immediately in Settings.", + "If disabled, messages form encrypted rooms won't appear in search results": "If disabled, messages form encrypted rooms won't appear in search results", + "Disable": "Disable", "Message search for encrypted rooms is disabled.": "Message search for encrypted rooms is disabled.", "Not downloading messages for any room.": "Not downloading messages for any room.", "Downloading mesages for %(currentRoom)s.": "Downloading mesages for %(currentRoom)s.", @@ -2042,9 +2045,8 @@ "Space used:": "Space used:", "Indexed messages:": "Indexed messages:", "Number of rooms:": "Number of rooms:", - "Download and index encrypted messages": "Download and index encrypted messages", - "Message downloading sleep time(ms)": "Message downloading sleep time(ms)", - "Disable": "Disable", + "Securely cache encrypted messages locally for them to appear in search results.": "Securely cache encrypted messages locally for them to appear in search results.", + "Enable": "Enable", "Failed to set direct chat tag": "Failed to set direct chat tag", "Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room", "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room"