From 4c101628b53d04eaf918ed201c1782d9b94f79be Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 9 Jan 2018 13:52:37 +0000 Subject: [PATCH 1/5] Add 'send without verifying' to status bar Fixes other part of https://github.com/vector-im/riot-web/issues/5936 --- src/components/structures/RoomStatusBar.js | 16 ++++++++++++++-- .../views/dialogs/UnknownDeviceDialog.js | 11 ++--------- src/cryptodevices.js | 14 ++++++++++++++ src/i18n/strings/en_EN.json | 7 ++++--- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index 20451453fb..595074224e 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -24,7 +24,11 @@ import WhoIsTyping from '../../WhoIsTyping'; import MatrixClientPeg from '../../MatrixClientPeg'; import MemberAvatar from '../views/avatars/MemberAvatar'; import Resend from '../../Resend'; -import { showUnknownDeviceDialogForMessages } from '../../cryptodevices'; +import { + showUnknownDeviceDialogForMessages, + markAllDevicesKnown, + getUnknownDevicesForRoom, + } from '../../cryptodevices'; const STATUS_BAR_HIDDEN = 0; const STATUS_BAR_EXPANDED = 1; @@ -148,6 +152,13 @@ module.exports = React.createClass({ }); }, + _onSendWithoutVerifyingClick: function() { + getUnknownDevicesForRoom(MatrixClientPeg.get(), this.props.room).then((devices) => { + markAllDevicesKnown(MatrixClientPeg.get(), devices); + Resend.resendUnsentEvents(this.props.room); + }); + }, + _onResendAllClick: function() { Resend.resendUnsentEvents(this.props.room); }, @@ -289,10 +300,11 @@ module.exports = React.createClass({ if (hasUDE) { title = _t("Message not sent due to unknown devices being present"); content = _t( - "Show devices or cancel all.", + "Show devices, send without verifying or cancel all.", {}, { 'showDevicesText': (sub) => { sub }, + 'sendAnywayText': (sub) => { sub }, 'cancelText': (sub) => { sub }, }, ); diff --git a/src/components/views/dialogs/UnknownDeviceDialog.js b/src/components/views/dialogs/UnknownDeviceDialog.js index 9c19ee6eca..b1e9c390e6 100644 --- a/src/components/views/dialogs/UnknownDeviceDialog.js +++ b/src/components/views/dialogs/UnknownDeviceDialog.js @@ -23,14 +23,7 @@ import GeminiScrollbar from 'react-gemini-scrollbar'; import Resend from '../../../Resend'; import { _t } from '../../../languageHandler'; import SettingsStore from "../../../settings/SettingsStore"; - -function markAllDevicesKnown(devices) { - Object.keys(devices).forEach((userId) => { - Object.keys(devices[userId]).map((deviceId) => { - MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true); - }); - }); -} +import { markAllDevicesKnown } from '../../../cryptodevices'; function DeviceListEntry(props) { const {userId, device} = props; @@ -141,7 +134,7 @@ export default React.createClass({ }, _onSendAnywayClicked: function() { - markAllDevicesKnown(this.props.devices); + markAllDevicesKnown(MatrixClientPeg.get(), this.props.devices); this.props.onFinished(); this.props.onSend(); diff --git a/src/cryptodevices.js b/src/cryptodevices.js index c93e04253f..8c16c96292 100644 --- a/src/cryptodevices.js +++ b/src/cryptodevices.js @@ -19,6 +19,20 @@ import sdk from './index'; import Modal from './Modal'; import { _t } from './languageHandler'; +/** + * Mark all given devices as 'known' + * + * @param {MatrixClient} matrixClient A MatrixClient + * @param {Object} map from userid -> deviceid -> deviceinfo + */ +export function markAllDevicesKnown(matrixClient, devices) { + Object.keys(devices).forEach((userId) => { + Object.keys(devices[userId]).map((deviceId) => { + matrixClient.setDeviceKnown(userId, deviceId, true); + }); + }); +} + /** * Gets all crypto devices in a room that are marked neither known * nor verified. diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ab503205f8..2f21d39e2f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -272,9 +272,9 @@ "Failed to mute user": "Failed to mute user", "Failed to toggle moderator status": "Failed to toggle moderator status", "Failed to change power level": "Failed to change power level", - "You will not be able to undo this change as you are promoting the user to have the same power level as yourself.": "You will not be able to undo this change as you are promoting the user to have the same power level as yourself.", "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.": "You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges.", "Are you sure?": "Are you sure?", + "You will not be able to undo this change as you are promoting the user to have the same power level as yourself.": "You will not be able to undo this change as you are promoting the user to have the same power level as yourself.", "No devices with registered encryption keys": "No devices with registered encryption keys", "Devices": "Devices", "Unignore": "Unignore", @@ -344,10 +344,10 @@ "Offline": "Offline", "Unknown": "Unknown", "Seen by %(userName)s at %(dateTime)s": "Seen by %(userName)s at %(dateTime)s", + "No rooms to show": "No rooms to show", "Unnamed room": "Unnamed room", "World readable": "World readable", "Guests can join": "Guests can join", - "No rooms to show": "No rooms to show", "Failed to set avatar.": "Failed to set avatar.", "Save": "Save", "(~%(count)s results)|other": "(~%(count)s results)", @@ -558,6 +558,7 @@ "Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?": "Deleting a widget removes it for all users in this room. Are you sure you want to delete this widget?", "Delete widget": "Delete widget", "Revoke widget access": "Revoke widget access", + "Minimize apps": "Minimize apps", "Edit": "Edit", "Create new room": "Create new room", "Unblacklist": "Unblacklist", @@ -774,7 +775,7 @@ "You have no visible notifications": "You have no visible notifications", "Scroll to bottom of page": "Scroll to bottom of page", "Message not sent due to unknown devices being present": "Message not sent due to unknown devices being present", - "Show devices or cancel all.": "Show devices or cancel all.", + "Show devices, send without verifying or cancel all.": "Show devices, send without verifying or cancel all.", "%(count)s of your messages have not been sent.|other": "Some of your messages have not been sent.", "%(count)s of your messages have not been sent.|one": "Your message was not sent.", "%(count)s Resend all or cancel all now. You can also select individual messages to resend or cancel.|other": "Resend all or cancel all now. You can also select individual messages to resend or cancel.", From dbb8f878cbea7ecb53855294764ed7db6a916d45 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 9 Jan 2018 17:57:18 +0000 Subject: [PATCH 2/5] Tidy up imports --- src/components/structures/RoomStatusBar.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index 595074224e..88f42b8d2a 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -24,11 +24,7 @@ import WhoIsTyping from '../../WhoIsTyping'; import MatrixClientPeg from '../../MatrixClientPeg'; import MemberAvatar from '../views/avatars/MemberAvatar'; import Resend from '../../Resend'; -import { - showUnknownDeviceDialogForMessages, - markAllDevicesKnown, - getUnknownDevicesForRoom, - } from '../../cryptodevices'; +import * as cryptodevices from '../../cryptodevices'; const STATUS_BAR_HIDDEN = 0; const STATUS_BAR_EXPANDED = 1; @@ -153,8 +149,8 @@ module.exports = React.createClass({ }, _onSendWithoutVerifyingClick: function() { - getUnknownDevicesForRoom(MatrixClientPeg.get(), this.props.room).then((devices) => { - markAllDevicesKnown(MatrixClientPeg.get(), devices); + cryptodevices.getUnknownDevicesForRoom(MatrixClientPeg.get(), this.props.room).then((devices) => { + cryptodevices.markAllDevicesKnown(MatrixClientPeg.get(), devices); Resend.resendUnsentEvents(this.props.room); }); }, @@ -168,7 +164,7 @@ module.exports = React.createClass({ }, _onShowDevicesClick: function() { - showUnknownDeviceDialogForMessages(MatrixClientPeg.get(), this.props.room); + cryptodevices.showUnknownDeviceDialogForMessages(MatrixClientPeg.get(), this.props.room); }, _onRoomLocalEchoUpdated: function(event, room, oldEventId, oldStatus) { From 9dd9a5be4b18c0001c701ea31b9ee9628872cdfe Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 9 Jan 2018 17:59:49 +0000 Subject: [PATCH 3/5] Wording tweak --- src/components/structures/RoomStatusBar.js | 2 +- src/i18n/strings/en_EN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index 88f42b8d2a..47da4096c0 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -296,7 +296,7 @@ module.exports = React.createClass({ if (hasUDE) { title = _t("Message not sent due to unknown devices being present"); content = _t( - "Show devices, send without verifying or cancel all.", + "Show devices, mark devices known and send or cancel all.", {}, { 'showDevicesText': (sub) => { sub }, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 2f21d39e2f..25b07751ae 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -775,7 +775,7 @@ "You have no visible notifications": "You have no visible notifications", "Scroll to bottom of page": "Scroll to bottom of page", "Message not sent due to unknown devices being present": "Message not sent due to unknown devices being present", - "Show devices, send without verifying or cancel all.": "Show devices, send without verifying or cancel all.", + "Show devices, mark devices known and send or cancel all.": "Show devices, mark devices known and send or cancel all.", "%(count)s of your messages have not been sent.|other": "Some of your messages have not been sent.", "%(count)s of your messages have not been sent.|one": "Your message was not sent.", "%(count)s Resend all or cancel all now. You can also select individual messages to resend or cancel.|other": "Resend all or cancel all now. You can also select individual messages to resend or cancel.", From 57e11cea1c06b908986605e6bcc72e43ed59d550 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 11 Jan 2018 10:27:15 +0000 Subject: [PATCH 5/5] Fix jsdoc --- src/cryptodevices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptodevices.js b/src/cryptodevices.js index 8c16c96292..c0b7e3da6e 100644 --- a/src/cryptodevices.js +++ b/src/cryptodevices.js @@ -23,7 +23,7 @@ import { _t } from './languageHandler'; * Mark all given devices as 'known' * * @param {MatrixClient} matrixClient A MatrixClient - * @param {Object} map from userid -> deviceid -> deviceinfo + * @param {Object} devices Map from userid -> deviceid -> deviceinfo */ export function markAllDevicesKnown(matrixClient, devices) { Object.keys(devices).forEach((userId) => {