From ae2645b69ba5ec7b7a5dea0561021e5ee9da5741 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 12 May 2020 12:42:16 +0100 Subject: [PATCH] Provide separate translatable for case where we have no device --- .../views/right_panel/VerificationPanel.js | 11 ++++++----- .../views/verification/VerificationShowSas.js | 16 ++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/components/views/right_panel/VerificationPanel.js b/src/components/views/right_panel/VerificationPanel.js index 76507d8d4f..6bb2d3646b 100644 --- a/src/components/views/right_panel/VerificationPanel.js +++ b/src/components/views/right_panel/VerificationPanel.js @@ -229,13 +229,14 @@ export default class VerificationPanel extends React.PureComponent { if (!device) { // This can happen if the device is logged out while we're still showing verification // UI for it. - // Leave the message slightly broken for this edge case (avoid adding a translatable string) console.warn("Verified device we don't know about: " + this.props.request.channel.deviceId); + description = _t("You've successfully verified your device!"); + } else { + description = _t("You've successfully verified %(deviceName)s (%(deviceId)s)!", { + deviceName: device ? device.getDisplayName() : '', + deviceId: this.props.request.channel.deviceId, + }); } - description = _t("You've successfully verified %(deviceName)s (%(deviceId)s)!", { - deviceName: device ? device.getDisplayName() : '', - deviceId: this.props.request.channel.deviceId, - }); } else { description = _t("You've successfully verified %(displayName)s!", { displayName: member.displayName || member.name || member.userId, diff --git a/src/components/views/verification/VerificationShowSas.js b/src/components/views/verification/VerificationShowSas.js index 251c8ca04f..09374b91af 100644 --- a/src/components/views/verification/VerificationShowSas.js +++ b/src/components/views/verification/VerificationShowSas.js @@ -117,12 +117,16 @@ export default class VerificationShowSas extends React.Component { let text; if (this.state.pending) { if (this.props.isSelf) { - // device shouldn't be null in this situation but it seems like it can be, so show - // slightly broken text rather than soft-crashing (we've already logged in VerificationPanel). - text = _t("Waiting for your other session, %(deviceName)s (%(deviceId)s), to verify…", { - deviceName: this.props.device ? this.props.device.getDisplayName() : '', - deviceId: this.props.device ? this.props.device.deviceId : '', - }); + // device shouldn't be null in this situation but it can be, eg. if the device is + // logged out during verification + if (this.props.device) { + text = _t("Waiting for your other session, %(deviceName)s (%(deviceId)s), to verify…", { + deviceName: this.props.device ? this.props.device.getDisplayName() : '', + deviceId: this.props.device ? this.props.device.deviceId : '', + }); + } else { + text = _t("Waiting for your other session to verify…"); + } } else { const {displayName} = this.props; text = _t("Waiting for %(displayName)s to verify…", {displayName});