From 3ec0301f9dd9d23f7e7aa41742fa2b54dbaf1f83 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 13 Feb 2020 17:28:10 +0100 Subject: [PATCH 1/3] use canAccept in toast, which takes local echo into account --- src/components/views/toasts/VerificationRequestToast.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/toasts/VerificationRequestToast.js b/src/components/views/toasts/VerificationRequestToast.js index a831505a05..4a881ae852 100644 --- a/src/components/views/toasts/VerificationRequestToast.js +++ b/src/components/views/toasts/VerificationRequestToast.js @@ -58,7 +58,7 @@ export default class VerificationRequestToast extends React.PureComponent { _checkRequestIsPending = () => { const {request} = this.props; - if (request.ready || request.done || request.cancelled || request.observeOnly) { + if (!request.canAccept) { ToastStore.sharedInstance().dismissToast(this.props.toastKey); } }; From 3eb07465f7709612e1b35865de78d3ea5d496c18 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 13 Feb 2020 17:29:13 +0100 Subject: [PATCH 2/3] use canAccept in tile, which takes local echo into account --- src/components/views/messages/MKeyVerificationRequest.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/views/messages/MKeyVerificationRequest.js b/src/components/views/messages/MKeyVerificationRequest.js index 9a48858bc7..0f5f417dbc 100644 --- a/src/components/views/messages/MKeyVerificationRequest.js +++ b/src/components/views/messages/MKeyVerificationRequest.js @@ -59,7 +59,6 @@ export default class MKeyVerificationRequest extends React.Component { }; _onAcceptClicked = async () => { - this.setState({acceptOrCancelClicked: true}); const request = this.props.mxEvent.verificationRequest; if (request) { try { @@ -72,7 +71,6 @@ export default class MKeyVerificationRequest extends React.Component { }; _onRejectClicked = async () => { - this.setState({acceptOrCancelClicked: true}); const request = this.props.mxEvent.verificationRequest; if (request) { try { @@ -137,11 +135,10 @@ export default class MKeyVerificationRequest extends React.Component { _t("%(name)s wants to verify", {name})}); subtitle = (
{ userLabelForEventRoom(request.requestingUserId, mxEvent.getRoomId())}
); - if (request.requested && !request.observeOnly) { - const disabled = this.state.acceptOrCancelClicked; + if (request.canAccept) { stateNode = (
- - + +
); } } else { // request sent by us From 3292991491b8dec2fc35d91999e135f0fe95b67f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 13 Feb 2020 17:29:38 +0100 Subject: [PATCH 3/3] provide specific label for when accepting/declining is in progress also distuingish between cancelling and declining --- .../views/messages/MKeyVerificationRequest.js | 24 +++++++++++++++---- src/i18n/strings/en_EN.json | 4 ++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/views/messages/MKeyVerificationRequest.js b/src/components/views/messages/MKeyVerificationRequest.js index 0f5f417dbc..d02319119e 100644 --- a/src/components/views/messages/MKeyVerificationRequest.js +++ b/src/components/views/messages/MKeyVerificationRequest.js @@ -94,10 +94,20 @@ export default class MKeyVerificationRequest extends React.Component { _cancelledLabel(userId) { const client = MatrixClientPeg.get(); const myUserId = client.getUserId(); + const {cancellationCode} = this.props.mxEvent.verificationRequest; + const declined = cancellationCode === "m.user"; if (userId === myUserId) { - return _t("You cancelled"); + if (declined) { + return _t("You declined"); + } else { + return _t("You cancelled"); + } } else { - return _t("%(name)s cancelled", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())}); + if (declined) { + return _t("%(name)s declined", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())}); + } else { + return _t("%(name)s cancelled", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())}); + } } } @@ -116,15 +126,19 @@ export default class MKeyVerificationRequest extends React.Component { let subtitle; let stateNode; - const accepted = request.ready || request.started || request.done; - if (accepted || request.cancelled) { + if (!request.canAccept) { let stateLabel; + const accepted = request.ready || request.started || request.done; if (accepted) { stateLabel = ( {this._acceptedLabel(request.receivingUserId)} ); - } else { + } else if (request.cancelled) { stateLabel = this._cancelledLabel(request.cancellingUserId); + } else if (request.accepting) { + stateLabel = _t("accepting …"); + } else if (request.declining) { + stateLabel = _t("declining …"); } stateNode = (
{stateLabel}
); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7a8642be95..eb0a66b79f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1239,8 +1239,12 @@ "%(name)s cancelled verifying": "%(name)s cancelled verifying", "You accepted": "You accepted", "%(name)s accepted": "%(name)s accepted", + "You declined": "You declined", "You cancelled": "You cancelled", + "%(name)s declined": "%(name)s declined", "%(name)s cancelled": "%(name)s cancelled", + "accepting …": "accepting …", + "declining …": "declining …", "%(name)s wants to verify": "%(name)s wants to verify", "You sent a verification request": "You sent a verification request", "Error decrypting video": "Error decrypting video",