From f12fe984e5275df6df6fd42d56526f5860658ff0 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 29 Jan 2020 15:00:01 +0000 Subject: [PATCH] Change new session toast to unverified This also changes text to show the device ID and name in the toast. Fixes https://github.com/vector-im/riot-web/issues/11916 --- res/css/structures/_ToastContainer.scss | 4 ++++ src/DeviceListener.js | 8 ++++---- ...sionToast.js => UnverifiedSessionToast.js} | 20 ++++++++++++------- src/i18n/strings/en_EN.json | 7 +++---- 4 files changed, 24 insertions(+), 15 deletions(-) rename src/components/views/toasts/{NewSessionToast.js => UnverifiedSessionToast.js} (76%) diff --git a/res/css/structures/_ToastContainer.scss b/res/css/structures/_ToastContainer.scss index 5b5c49f357..d1687743d6 100644 --- a/res/css/structures/_ToastContainer.scss +++ b/res/css/structures/_ToastContainer.scss @@ -98,5 +98,9 @@ limitations under the License. margin: 4px 0 11px 0; font-size: 12px; } + + .mx_Toast_deviceID { + font-size: 10px; + } } } diff --git a/src/DeviceListener.js b/src/DeviceListener.js index 630d1a61c0..4bc6ce2097 100644 --- a/src/DeviceListener.js +++ b/src/DeviceListener.js @@ -21,7 +21,7 @@ import { _t } from './languageHandler'; import ToastStore from './stores/ToastStore'; function toastKey(deviceId) { - return 'newsession_' + deviceId; + return 'unverified_session_' + deviceId; } const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000; @@ -160,10 +160,10 @@ export default class DeviceListener { this._activeNagToasts.add(device.deviceId); ToastStore.sharedInstance().addOrReplaceToast({ key: toastKey(device.deviceId), - title: _t("New Session"), + title: _t("Unverified session"), icon: "verification_warning", - props: {deviceId: device.deviceId}, - component: sdk.getComponent("toasts.NewSessionToast"), + props: { device }, + component: sdk.getComponent("toasts.UnverifiedSessionToast"), }); newActiveToasts.add(device.deviceId); } diff --git a/src/components/views/toasts/NewSessionToast.js b/src/components/views/toasts/UnverifiedSessionToast.js similarity index 76% rename from src/components/views/toasts/NewSessionToast.js rename to src/components/views/toasts/UnverifiedSessionToast.js index 80564f3494..cf982741a1 100644 --- a/src/components/views/toasts/NewSessionToast.js +++ b/src/components/views/toasts/UnverifiedSessionToast.js @@ -24,11 +24,11 @@ import NewSessionReviewDialog from '../dialogs/NewSessionReviewDialog'; import FormButton from '../elements/FormButton'; import { replaceableComponent } from '../../../utils/replaceableComponent'; -@replaceableComponent("views.toasts.VerifySessionToast") -export default class VerifySessionToast extends React.PureComponent { +@replaceableComponent("views.toasts.UnverifiedSessionToast") +export default class UnverifiedSessionToast extends React.PureComponent { static propTypes = { toastKey: PropTypes.string.isRequired, - deviceId: PropTypes.string, + device: PropTypes.object.isRequired, }; _onLaterClick = () => { @@ -36,9 +36,7 @@ export default class VerifySessionToast extends React.PureComponent { }; _onReviewClick = async () => { - const cli = MatrixClientPeg.get(); - - const device = await cli.getStoredDevice(cli.getUserId(), this.props.deviceId); + const { device } = this.props; Modal.createTrackedDialog('New Session Review', 'Starting dialog', NewSessionReviewDialog, { userId: MatrixClientPeg.get().getUserId(), @@ -47,8 +45,16 @@ export default class VerifySessionToast extends React.PureComponent { }; render() { + const { device } = this.props; + return (
-
{_t("Review & verify your new session")}
+
+ + {device.getDisplayName()} + + ({device.deviceId}) + +
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3ae0991f16..c064c7c8fd 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -91,7 +91,7 @@ "Verify this session": "Verify this session", "Encryption upgrade available": "Encryption upgrade available", "Set up encryption": "Set up encryption", - "New Session": "New Session", + "Unverified session": "Unverified session", "Who would you like to add to this community?": "Who would you like to add to this community?", "Warning: any person you add to a community will be publicly visible to anyone who knows the community ID": "Warning: any person you add to a community will be publicly visible to anyone who knows the community ID", "Invite new community members": "Invite new community members", @@ -516,13 +516,12 @@ "Headphones": "Headphones", "Folder": "Folder", "Pin": "Pin", - "Review & verify your new session": "Review & verify your new session", - "Later": "Later", - "Review": "Review", "Verify your other devices easier": "Verify your other devices easier", "Other users may not trust it": "Other users may not trust it", "Upgrade": "Upgrade", "Verify": "Verify", + "Later": "Later", + "Review": "Review", "Decline (%(counter)s)": "Decline (%(counter)s)", "Accept to continue:": "Accept to continue:", "Upload": "Upload",