From 6d296a0e7a02147b5c7681812372ec02f183a166 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 1 Mar 2017 15:41:13 +0000 Subject: [PATCH 1/3] Warn users about using e2e for the first time --- src/components/structures/RoomView.js | 30 +++++++++++++++++++ .../views/dialogs/QuestionDialog.js | 11 ++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index acdea38c69..940c96b640 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -493,10 +493,40 @@ module.exports = React.createClass({ // called when state.room is first initialised (either at initial load, // after a successful peek, or after we join the room). _onRoomLoaded: function(room) { + this._warnAboutEncryption(room); this._calculatePeekRules(room); this._updatePreviewUrlVisibility(room); }, + _warnAboutEncryption: function (room) { + if (!MatrixClientPeg.get().isRoomEncrypted(room.roomId)) { + return; + } + let userHasUsedEncryption = false; + if (localStorage) { + userHasUsedEncryption = localStorage.getItem('mx_user_has_used_encryption'); + } + if (!userHasUsedEncryption) { + var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + Modal.createDialog(QuestionDialog, { + title: "Warning!", + hasCancelButton: false, + description: ( +
+

End-to-end encryption is in beta and may not be reliable.

+

You should not yet trust it to secure data.

+

Devices will not yet be able to decrypt history from before they joined the room.

+

Once encryption is enabled for a room it cannot be turned off again (for now).

+

Encrypted messages will not be visible on clients that do not yet implement encryption.

+
+ ), + }); + } + if (localStorage) { + localStorage.setItem('mx_user_has_used_encryption', true); + } + }, + _calculatePeekRules: function(room) { var guestAccessEvent = room.currentState.getStateEvents("m.room.guest_access", ""); if (guestAccessEvent && guestAccessEvent.getContent().guest_access === "can_join") { diff --git a/src/components/views/dialogs/QuestionDialog.js b/src/components/views/dialogs/QuestionDialog.js index 3f7f237c30..0260fc29e2 100644 --- a/src/components/views/dialogs/QuestionDialog.js +++ b/src/components/views/dialogs/QuestionDialog.js @@ -36,6 +36,7 @@ export default React.createClass({ description: "", button: "OK", focus: true, + hasCancelButton: true, }; }, @@ -49,6 +50,11 @@ export default React.createClass({ render: function() { const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); + const cancelButton = this.props.hasCancelButton ? ( + + ) : null; return ( {this.props.button} - - + {cancelButton} ); From 187c91b76a4e8db6d8ef15288e173bad4a762995 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 1 Mar 2017 15:42:05 +0000 Subject: [PATCH 2/3] Adjust warning message --- src/components/structures/RoomView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 940c96b640..854b154505 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -516,7 +516,6 @@ module.exports = React.createClass({

End-to-end encryption is in beta and may not be reliable.

You should not yet trust it to secure data.

Devices will not yet be able to decrypt history from before they joined the room.

-

Once encryption is enabled for a room it cannot be turned off again (for now).

Encrypted messages will not be visible on clients that do not yet implement encryption.

), From b7bd93c613cc25c4ce90a7d9efa93b47ff800dc4 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 1 Mar 2017 15:55:15 +0000 Subject: [PATCH 3/3] var -> const --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 854b154505..1fab9315bf 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -507,7 +507,7 @@ module.exports = React.createClass({ userHasUsedEncryption = localStorage.getItem('mx_user_has_used_encryption'); } if (!userHasUsedEncryption) { - var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); Modal.createDialog(QuestionDialog, { title: "Warning!", hasCancelButton: false,