diff --git a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js index a6eca3bf194..f4293a60dc2 100644 --- a/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/SecurityRoomSettingsTab.js @@ -21,6 +21,8 @@ import MatrixClientPeg from "../../../../../MatrixClientPeg"; import sdk from "../../../../.."; import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch"; import {SettingLevel} from "../../../../../settings/SettingsStore"; +import Modal from "../../../../../Modal"; +import QuestionDialog from "../../../dialogs/QuestionDialog"; export default class SecurityRoomSettingsTab extends React.Component { static propTypes = { @@ -83,14 +85,36 @@ export default class SecurityRoomSettingsTab extends React.Component { }; _onEncryptionChange = (e) => { - const beforeEncrypted = this.state.encrypted; - this.setState({encrypted: true}); - MatrixClientPeg.get().sendStateEvent( - this.props.roomId, "m.room.encryption", - { algorithm: "m.megolm.v1.aes-sha2" }, - ).catch((e) => { - console.error(e); - this.setState({encrypted: beforeEncrypted}); + Modal.createTrackedDialog('Enable encryption', '', QuestionDialog, { + title: _t('Enable encryption?'), + description: _t( + "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted " + + "room cannot be seen by the server, only by the participants of the room. Enabling encryption " + + "may prevent many bots and bridges from working correctly. Learn more about encryption.", + {}, + { + 'a': (sub) => { + return {sub}; + }, + }, + ), + onFinished: (confirm) => { + if (!confirm) { + this.setState({encrypted: false}); + return; + } + + const beforeEncrypted = this.state.encrypted; + this.setState({encrypted: true}); + MatrixClientPeg.get().sendStateEvent( + this.props.roomId, "m.room.encryption", + { algorithm: "m.megolm.v1.aes-sha2" }, + ).catch((e) => { + console.error(e); + this.setState({encrypted: beforeEncrypted}); + }); + }, }); }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 19259c63413..7469d5f69ca 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -614,6 +614,8 @@ "Roles & Permissions": "Roles & Permissions", "Permissions": "Permissions", "Select the roles required to change various parts of the room": "Select the roles required to change various parts of the room", + "Enable encryption?": "Enable encryption?", + "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. Learn more about encryption.", "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", "Click here to fix": "Click here to fix", "To link to this room, please add an alias.": "To link to this room, please add an alias.",