ManageEventIndex: Hook up the disable event index button.
							parent
							
								
									4aa0658ac8
								
							
						
					
					
						commit
						64c4ad2eb9
					
				| 
						 | 
				
			
			@ -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 (
 | 
			
		||||
            <BaseDialog className='mx_ManageEventIndexDialog'
 | 
			
		||||
                onFinished={this.props.onFinished}
 | 
			
		||||
                title={_t("Are you sure?")}
 | 
			
		||||
            >
 | 
			
		||||
            {_t("If disabled, messages form encrypted rooms won't appear in search results")}
 | 
			
		||||
            <DialogButtons
 | 
			
		||||
                primaryButton={_t("Disable")}
 | 
			
		||||
                onPrimaryButtonClick={this._onDisable}
 | 
			
		||||
                cancelButton={_t("Cancel")}
 | 
			
		||||
                onCancel={this.props.onFinished}
 | 
			
		||||
            />
 | 
			
		||||
            </BaseDialog>
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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 () => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue