From 4c101628b53d04eaf918ed201c1782d9b94f79be Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 9 Jan 2018 13:52:37 +0000 Subject: [PATCH] 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.",