/* Copyright 2018, 2019 New Vector Ltd 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 Modal from '../../../Modal'; import sdk from '../../../index'; import dis from '../../../dispatcher'; import { _t } from '../../../languageHandler'; import MatrixClientPeg from '../../../MatrixClientPeg'; import SettingsStore from "../../../settings/SettingsStore"; export default class LogoutDialog extends React.Component { constructor() { super(); this._onSettingsLinkClick = this._onSettingsLinkClick.bind(this); this._onExportE2eKeysClicked = this._onExportE2eKeysClicked.bind(this); this._onFinished = this._onFinished.bind(this); this._onSetRecoveryMethodClick = this._onSetRecoveryMethodClick.bind(this); this._onLogoutConfirm = this._onLogoutConfirm.bind(this); } _onSettingsLinkClick() { // close dialog if (this.props.onFinished) { this.props.onFinished(); } } _onExportE2eKeysClicked() { Modal.createTrackedDialogAsync('Export E2E Keys', '', import('../../../async-components/views/dialogs/ExportE2eKeysDialog'), { matrixClient: MatrixClientPeg.get(), }, ); } _onFinished(confirmed) { if (confirmed) { dis.dispatch({action: 'logout'}); } // close dialog if (this.props.onFinished) { this.props.onFinished(); } } _onSetRecoveryMethodClick() { Modal.createTrackedDialogAsync('Key Backup', 'Key Backup', import('../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'), ); // close dialog if (this.props.onFinished) { this.props.onFinished(); } } _onLogoutConfirm() { dis.dispatch({action: 'logout'}); // close dialog if (this.props.onFinished) { this.props.onFinished(); } } render() { let description; if (SettingsStore.isFeatureEnabled("feature_keybackup")) { description =
{_t( "When you log out, you'll lose your secure message history. To prevent " + "this, set up a recovery method.", )}
{_t( "Alternatively, advanced users can also manually export encryption keys in " + "Settings before logging out.", {}, { a: sub => {sub}, }, )}