From 565e41c3dfb24b3a318ee46d4e41a9dd4fe60528 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Wed, 12 May 2021 17:04:24 +0100
Subject: [PATCH 1/3] Extract UntrustedDeviceDialog and fix e2ee icon
---
res/css/_components.scss | 1 +
.../views/dialogs/_UntrustedDeviceDialog.scss | 26 ++++++++
.../views/dialogs/UntrustedDeviceDialog.js | 61 +++++++++++++++++++
src/verification.js | 35 +----------
4 files changed, 89 insertions(+), 34 deletions(-)
create mode 100644 res/css/views/dialogs/_UntrustedDeviceDialog.scss
create mode 100644 src/components/views/dialogs/UntrustedDeviceDialog.js
diff --git a/res/css/_components.scss b/res/css/_components.scss
index d8e5247f9d..c8985cbb51 100644
--- a/res/css/_components.scss
+++ b/res/css/_components.scss
@@ -98,6 +98,7 @@
@import "./views/dialogs/_SpaceSettingsDialog.scss";
@import "./views/dialogs/_TabbedIntegrationManagerDialog.scss";
@import "./views/dialogs/_TermsDialog.scss";
+@import "./views/dialogs/_UntrustedDeviceDialog.scss";
@import "./views/dialogs/_UploadConfirmDialog.scss";
@import "./views/dialogs/_UserSettingsDialog.scss";
@import "./views/dialogs/_WidgetCapabilitiesPromptDialog.scss";
diff --git a/res/css/views/dialogs/_UntrustedDeviceDialog.scss b/res/css/views/dialogs/_UntrustedDeviceDialog.scss
new file mode 100644
index 0000000000..0ecd9d4f71
--- /dev/null
+++ b/res/css/views/dialogs/_UntrustedDeviceDialog.scss
@@ -0,0 +1,26 @@
+/*
+Copyright 2021 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.
+*/
+
+.mx_UntrustedDeviceDialog {
+ .mx_Dialog_title {
+ display: flex;
+ align-items: center;
+
+ .mx_E2EIcon {
+ margin-left: 0;
+ }
+ }
+}
diff --git a/src/components/views/dialogs/UntrustedDeviceDialog.js b/src/components/views/dialogs/UntrustedDeviceDialog.js
new file mode 100644
index 0000000000..11cbef39a1
--- /dev/null
+++ b/src/components/views/dialogs/UntrustedDeviceDialog.js
@@ -0,0 +1,61 @@
+/*
+Copyright 2019, 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 { _t } from '../../../languageHandler';
+import * as sdk from '../../../index';
+import {MatrixClientPeg} from '../../../MatrixClientPeg';
+import E2EIcon from "../rooms/E2EIcon";
+
+function UntrustedDeviceDialog(props) {
+ const {device, user, onFinished} = props;
+ const BaseDialog = sdk.getComponent("dialogs.BaseDialog");
+ const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
+ let askToVerifyText;
+ let newSessionText;
+
+ if (MatrixClientPeg.get().getUserId() === user.userId) {
+ newSessionText = _t("You signed in to a new session without verifying it:");
+ askToVerifyText = _t("Verify your other session using one of the options below.");
+ } else {
+ newSessionText = _t("%(name)s (%(userId)s) signed in to a new session without verifying it:",
+ {name: user.displayName, userId: user.userId});
+ askToVerifyText = _t("Ask this user to verify their session, or manually verify it below.");
+ }
+
+ return
+
+ { _t("Not Trusted")}
+ >}
+ >
+
+
{newSessionText}
+
{device.getDisplayName()} ({device.deviceId})
+
{askToVerifyText}
+
+
+ onFinished("legacy")}>{_t("Manually Verify by Text")}
+ onFinished("sas")}>{_t("Interactively verify by Emoji")}
+ onFinished()}>{_t("Done")}
+
+ ;
+}
+
+export default UntrustedDeviceDialog;
diff --git a/src/verification.js b/src/verification.js
index 74e3897d3a..69577384a1 100644
--- a/src/verification.js
+++ b/src/verification.js
@@ -18,12 +18,12 @@ import {MatrixClientPeg} from './MatrixClientPeg';
import dis from "./dispatcher/dispatcher";
import Modal from './Modal';
import * as sdk from './index';
-import { _t } from './languageHandler';
import {RightPanelPhases} from "./stores/RightPanelStorePhases";
import {findDMForUser} from './createRoom';
import {accessSecretStorage} from './SecurityManager';
import {verificationMethods} from 'matrix-js-sdk/src/crypto';
import {Action} from './dispatcher/actions';
+import UntrustedDeviceDialog from "./components/views/dialogs/UntrustedDeviceDialog";
async function enable4SIfNeeded() {
const cli = MatrixClientPeg.get();
@@ -39,39 +39,6 @@ async function enable4SIfNeeded() {
return true;
}
-function UntrustedDeviceDialog(props) {
- const {device, user, onFinished} = props;
- const BaseDialog = sdk.getComponent("dialogs.BaseDialog");
- const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
- let askToVerifyText;
- let newSessionText;
-
- if (MatrixClientPeg.get().getUserId() === user.userId) {
- newSessionText = _t("You signed in to a new session without verifying it:");
- askToVerifyText = _t("Verify your other session using one of the options below.");
- } else {
- newSessionText = _t("%(name)s (%(userId)s) signed in to a new session without verifying it:",
- {name: user.displayName, userId: user.userId});
- askToVerifyText = _t("Ask this user to verify their session, or manually verify it below.");
- }
-
- return
-
-
{newSessionText}
-
{device.getDisplayName()} ({device.deviceId})
-
{askToVerifyText}
-
-
- onFinished("legacy")}>{_t("Manually Verify by Text")}
- onFinished("sas")}>{_t("Interactively verify by Emoji")}
- onFinished()}>{_t("Done")}
-
- ;
-}
-
export async function verifyDevice(user, device) {
const cli = MatrixClientPeg.get();
if (cli.isGuest()) {
From 5430f44c2746faa181a9f37264bdf69b186ceaaf Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Wed, 12 May 2021 17:08:44 +0100
Subject: [PATCH 2/3] Convert verification and UntrustedDeviceDialog to TS
---
...iceDialog.js => UntrustedDeviceDialog.tsx} | 38 ++++++++++++-------
src/components/views/right_panel/UserInfo.tsx | 2 +-
src/{verification.js => verification.ts} | 25 ++++++------
3 files changed, 40 insertions(+), 25 deletions(-)
rename src/components/views/dialogs/{UntrustedDeviceDialog.js => UntrustedDeviceDialog.tsx} (67%)
rename src/{verification.js => verification.ts} (83%)
diff --git a/src/components/views/dialogs/UntrustedDeviceDialog.js b/src/components/views/dialogs/UntrustedDeviceDialog.tsx
similarity index 67%
rename from src/components/views/dialogs/UntrustedDeviceDialog.js
rename to src/components/views/dialogs/UntrustedDeviceDialog.tsx
index 11cbef39a1..da1492e30d 100644
--- a/src/components/views/dialogs/UntrustedDeviceDialog.js
+++ b/src/components/views/dialogs/UntrustedDeviceDialog.tsx
@@ -1,5 +1,5 @@
/*
-Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
+Copyright 2019, 2020, 2021 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.
@@ -14,17 +14,23 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React from 'react';
+import React from "react";
+import { User } from "matrix-js-sdk/src/models/user";
-import { _t } from '../../../languageHandler';
-import * as sdk from '../../../index';
-import {MatrixClientPeg} from '../../../MatrixClientPeg';
+import { _t } from "../../../languageHandler";
+import { MatrixClientPeg } from "../../../MatrixClientPeg";
import E2EIcon from "../rooms/E2EIcon";
+import AccessibleButton from "../elements/AccessibleButton";
+import BaseDialog from "./BaseDialog";
+import { IDialogProps } from "./IDialogProps";
+import { IDevice } from "../right_panel/UserInfo";
-function UntrustedDeviceDialog(props) {
- const {device, user, onFinished} = props;
- const BaseDialog = sdk.getComponent("dialogs.BaseDialog");
- const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
+interface IProps extends IDialogProps {
+ user: User;
+ device: IDevice;
+}
+
+const UntrustedDeviceDialog: React.FC = ({device, user, onFinished}) => {
let askToVerifyText;
let newSessionText;
@@ -51,11 +57,17 @@ function UntrustedDeviceDialog(props) {
{askToVerifyText}
- onFinished("legacy")}>{_t("Manually Verify by Text")}
- onFinished("sas")}>{_t("Interactively verify by Emoji")}
- onFinished()}>{_t("Done")}
+ onFinished("legacy")}>
+ { _t("Manually Verify by Text") }
+
+ onFinished("sas")}>
+ { _t("Interactively verify by Emoji") }
+
+ onFinished(false)}>
+ { _t("Done") }
+
;
-}
+};
export default UntrustedDeviceDialog;
diff --git a/src/components/views/right_panel/UserInfo.tsx b/src/components/views/right_panel/UserInfo.tsx
index faf8860cad..d5f67623a2 100644
--- a/src/components/views/right_panel/UserInfo.tsx
+++ b/src/components/views/right_panel/UserInfo.tsx
@@ -67,7 +67,7 @@ import RoomAvatar from "../avatars/RoomAvatar";
import RoomName from "../elements/RoomName";
import {mediaFromMxc} from "../../../customisations/Media";
-interface IDevice {
+export interface IDevice {
deviceId: string;
ambiguous?: boolean;
getDisplayName(): string;
diff --git a/src/verification.js b/src/verification.ts
similarity index 83%
rename from src/verification.js
rename to src/verification.ts
index 69577384a1..acd9f6d2b2 100644
--- a/src/verification.js
+++ b/src/verification.ts
@@ -1,5 +1,5 @@
/*
-Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
+Copyright 2019, 2020, 2021 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.
@@ -14,16 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import {MatrixClientPeg} from './MatrixClientPeg';
+import { User } from "matrix-js-sdk/src/models/user";
+
+import { MatrixClientPeg } from './MatrixClientPeg';
import dis from "./dispatcher/dispatcher";
import Modal from './Modal';
import * as sdk from './index';
-import {RightPanelPhases} from "./stores/RightPanelStorePhases";
-import {findDMForUser} from './createRoom';
-import {accessSecretStorage} from './SecurityManager';
-import {verificationMethods} from 'matrix-js-sdk/src/crypto';
-import {Action} from './dispatcher/actions';
+import { RightPanelPhases } from "./stores/RightPanelStorePhases";
+import { findDMForUser } from './createRoom';
+import { accessSecretStorage } from './SecurityManager';
+import { verificationMethods } from 'matrix-js-sdk/src/crypto';
+import { Action } from './dispatcher/actions';
import UntrustedDeviceDialog from "./components/views/dialogs/UntrustedDeviceDialog";
+import {IDevice} from "./components/views/right_panel/UserInfo";
async function enable4SIfNeeded() {
const cli = MatrixClientPeg.get();
@@ -39,7 +42,7 @@ async function enable4SIfNeeded() {
return true;
}
-export async function verifyDevice(user, device) {
+export async function verifyDevice(user: User, device: IDevice) {
const cli = MatrixClientPeg.get();
if (cli.isGuest()) {
dis.dispatch({action: 'require_registration'});
@@ -82,7 +85,7 @@ export async function verifyDevice(user, device) {
});
}
-export async function legacyVerifyUser(user) {
+export async function legacyVerifyUser(user: User) {
const cli = MatrixClientPeg.get();
if (cli.isGuest()) {
dis.dispatch({action: 'require_registration'});
@@ -102,7 +105,7 @@ export async function legacyVerifyUser(user) {
});
}
-export async function verifyUser(user) {
+export async function verifyUser(user: User) {
const cli = MatrixClientPeg.get();
if (cli.isGuest()) {
dis.dispatch({action: 'require_registration'});
@@ -122,7 +125,7 @@ export async function verifyUser(user) {
});
}
-export function pendingVerificationRequestForUser(user) {
+export function pendingVerificationRequestForUser(user: User) {
const cli = MatrixClientPeg.get();
const dmRoom = findDMForUser(cli, user.userId);
if (dmRoom) {
From 236fcecf9cac5e97f5de92cc1458bffb6ac41878 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Wed, 12 May 2021 17:13:23 +0100
Subject: [PATCH 3/3] i18n
---
src/i18n/strings/en_EN.json | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index da58680424..b977c2073a 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -578,14 +578,6 @@
"%(senderName)s updated a ban rule that was matching %(oldGlob)s to matching %(newGlob)s for %(reason)s": "%(senderName)s updated a ban rule that was matching %(oldGlob)s to matching %(newGlob)s for %(reason)s",
"Light": "Light",
"Dark": "Dark",
- "You signed in to a new session without verifying it:": "You signed in to a new session without verifying it:",
- "Verify your other session using one of the options below.": "Verify your other session using one of the options below.",
- "%(name)s (%(userId)s) signed in to a new session without verifying it:": "%(name)s (%(userId)s) signed in to a new session without verifying it:",
- "Ask this user to verify their session, or manually verify it below.": "Ask this user to verify their session, or manually verify it below.",
- "Not Trusted": "Not Trusted",
- "Manually Verify by Text": "Manually Verify by Text",
- "Interactively verify by Emoji": "Interactively verify by Emoji",
- "Done": "Done",
"%(displayName)s is typing …": "%(displayName)s is typing …",
"%(names)s and %(count)s others are typing …|other": "%(names)s and %(count)s others are typing …",
"%(names)s and %(count)s others are typing …|one": "%(names)s and one other is typing …",
@@ -2066,6 +2058,7 @@
"Close dialog": "Close dialog",
"Beta feedback": "Beta feedback",
"Thank you for your feedback, we really appreciate it.": "Thank you for your feedback, we really appreciate it.",
+ "Done": "Done",
"Your platform and username will be noted to help us use your feedback as much as we can.": "Your platform and username will be noted to help us use your feedback as much as we can.",
"To leave the beta, visit your settings.": "To leave the beta, visit your settings.",
"Feedback": "Feedback",
@@ -2388,6 +2381,13 @@
"Summary": "Summary",
"Document": "Document",
"Next": "Next",
+ "You signed in to a new session without verifying it:": "You signed in to a new session without verifying it:",
+ "Verify your other session using one of the options below.": "Verify your other session using one of the options below.",
+ "%(name)s (%(userId)s) signed in to a new session without verifying it:": "%(name)s (%(userId)s) signed in to a new session without verifying it:",
+ "Ask this user to verify their session, or manually verify it below.": "Ask this user to verify their session, or manually verify it below.",
+ "Not Trusted": "Not Trusted",
+ "Manually Verify by Text": "Manually Verify by Text",
+ "Interactively verify by Emoji": "Interactively verify by Emoji",
"Upload files (%(current)s of %(total)s)": "Upload files (%(current)s of %(total)s)",
"Upload files": "Upload files",
"Upload all": "Upload all",