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

Commit c478b4e

Browse files
committed
Improve "Are you sure you want to make this encrypted room public?" dialog
Signed-off-by: Šimon Brandner <[email protected]>
1 parent 0618460 commit c478b4e

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

res/css/_common.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus {
381381
font-size: $font-14px;
382382
color: $primary-fg-color;
383383
word-wrap: break-word;
384+
385+
a {
386+
color: $accent-color;
387+
cursor: pointer;
388+
}
384389
}
385390

386391
.mx_Dialog_buttons {

src/components/views/settings/tabs/room/SecurityRoomSettingsTab.tsx

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import SettingsStore from "../../../../../settings/SettingsStore";
2727
import { UIFeature } from "../../../../../settings/UIFeature";
2828
import { replaceableComponent } from "../../../../../utils/replaceableComponent";
2929
import SettingsFlag from '../../../elements/SettingsFlag';
30+
import createRoom, { IOpts } from '../../../../../createRoom';
31+
import CreateRoomDialog from '../../../dialogs/CreateRoomDialog';
3032

3133
// Knock and private are reserved keywords which are not yet implemented.
3234
export enum JoinRule {
@@ -124,7 +126,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
124126
if (refreshWhenTypes.includes(e.getType())) this.forceUpdate();
125127
};
126128

127-
private onEncryptionChange = async (e: React.ChangeEvent) => {
129+
private onEncryptionChange = async () => {
128130
if (this.state.joinRule == "public") {
129131
const { finished } = Modal.createTrackedDialog('Confirm Public Encrypted Room', '', QuestionDialog, {
130132
title: _t('Enable encryption in a public room?'),
@@ -262,20 +264,47 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
262264
});
263265
};
264266

267+
private createNewRoom = async (defaultPublic: boolean) => {
268+
const modal = Modal.createTrackedDialog<[boolean, IOpts]>(
269+
"Create Room",
270+
"Create room after trying to make an E2EE room public",
271+
CreateRoomDialog,
272+
{ defaultPublic },
273+
);
274+
const [shouldCreate, opts] = await modal.finished;
275+
if (shouldCreate) {
276+
await createRoom(opts);
277+
}
278+
return shouldCreate;
279+
};
280+
265281
private onRoomAccessRadioToggle = (roomAccess) => {
266282
if (
267283
this.state.encrypted &&
268284
this.state.joinRule != "public" &&
269285
roomAccess != "invite_only"
270286
) {
271-
Modal.createTrackedDialog('Confirm Public Encrypted Room', '', QuestionDialog, {
272-
title: _t('Confirm making this room public?'),
273-
description: _t(
274-
"Making end-to-end encrypted rooms public renders the " +
275-
"encryption pointless, wastes processing power, and can cause " +
276-
"performance problems. Please consider creating a separate " +
277-
"unencrypted public room.",
278-
),
287+
const dialog = Modal.createTrackedDialog('Confirm Public Encrypted Room', '', QuestionDialog, {
288+
title: _t("Are you sure you want to make this encrypted room public?"),
289+
description: <div>
290+
<p> { _t(
291+
"<b> It’s not recommended to make end-to-end encrypted rooms public. </b> It " +
292+
"means anyone can find and join this room, so anyone can read messages. You’ll " +
293+
"get none of the benefits of encryption. Encrypting messages in a public room " +
294+
"will also likely make receiving and sending messages slower than necessary.",
295+
null,
296+
{ "b": (sub) => <b> { sub } </b> },
297+
)} </p>
298+
<p> { _t(
299+
"To avoid these issues, create a <a> new public room </a> for the conversation " +
300+
"you plan to have.",
301+
null,
302+
{ "a": (sub) => <a onClick={() => {
303+
dialog.close();
304+
this.createNewRoom(true);
305+
}}> {sub} </a> },
306+
)} </p>
307+
</div>,
279308
onFinished: (confirm) => {
280309
if (confirm) this._setRoomAccess(roomAccess);
281310
},

src/i18n/strings/en_EN.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,9 @@
14371437
"Note that enabling encryption in public rooms renders the encryption pointless, wastes processing power, and can cause performance problems. Please consider creating a separate encrypted room.": "Note that enabling encryption in public rooms renders the encryption pointless, wastes processing power, and can cause performance problems. Please consider creating a separate encrypted room.",
14381438
"Enable encryption?": "Enable encryption?",
14391439
"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. <a>Learn more about encryption.</a>": "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. <a>Learn more about encryption.</a>",
1440-
"Confirm making this room public?": "Confirm making this room public?",
1441-
"Making end-to-end encrypted rooms public renders the encryption pointless, wastes processing power, and can cause performance problems. Please consider creating a separate unencrypted public room.": "Making end-to-end encrypted rooms public renders the encryption pointless, wastes processing power, and can cause performance problems. Please consider creating a separate unencrypted public room.",
1440+
"Are you sure you want to make this encrypted room public?": "Are you sure you want to make this encrypted room public?",
1441+
"<b> It’s not recommended to make end-to-end encrypted rooms public. </b> It means anyone can find and join this room, so anyone can read messages. You’ll get none of the benefits of encryption. Encrypting messages in a public room will also likely make receiving and sending messages slower than necessary.": "<b> It’s not recommended to make end-to-end encrypted rooms public. </b> It means anyone can find and join this room, so anyone can read messages. You’ll get none of the benefits of encryption. Encrypting messages in a public room will also likely make receiving and sending messages slower than necessary.",
1442+
"To avoid these issues, create a <a> new public room </a> for the conversation you plan to have.": "To avoid these issues, create a <a> new public room </a> for the conversation you plan to have.",
14421443
"Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.",
14431444
"Click here to fix": "Click here to fix",
14441445
"To link to this room, please add an address.": "To link to this room, please add an address.",

0 commit comments

Comments
 (0)