From fa13bb96893d242efff8250b13d083cea954ce31 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 30 Jan 2020 18:50:44 +0100 Subject: [PATCH 1/4] make the verif toast work with to_device request that do .request/.ready --- .../views/toasts/VerificationRequestToast.js | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/components/views/toasts/VerificationRequestToast.js b/src/components/views/toasts/VerificationRequestToast.js index 5125e20261..0c5d29ebe6 100644 --- a/src/components/views/toasts/VerificationRequestToast.js +++ b/src/components/views/toasts/VerificationRequestToast.js @@ -58,10 +58,7 @@ export default class VerificationRequestToast extends React.PureComponent { _checkRequestIsPending = () => { const {request} = this.props; - const isPendingInRoomRequest = request.channel.roomId && - !(request.ready || request.started || request.done || request.cancelled || request.observeOnly); - const isPendingDeviceRequest = request.channel.deviceId && request.started; - if (!isPendingInRoomRequest && !isPendingDeviceRequest) { + if (request.done || request.cancelled || request.observeOnly) { ToastStore.sharedInstance().dismissToast(this.props.toastKey); } }; @@ -79,6 +76,7 @@ export default class VerificationRequestToast extends React.PureComponent { ToastStore.sharedInstance().dismissToast(this.props.toastKey); const {request} = this.props; // no room id for to_device requests + const cli = MatrixClientPeg.get(); try { if (request.channel.roomId) { dis.dispatch({ @@ -86,23 +84,29 @@ export default class VerificationRequestToast extends React.PureComponent { room_id: request.channel.roomId, should_peek: false, }); - await request.accept(); - const cli = MatrixClientPeg.get(); + } else { dis.dispatch({ - action: "set_right_panel_phase", - phase: RIGHT_PANEL_PHASES.EncryptionPanel, - refireParams: { - verificationRequest: request, - member: cli.getUser(request.otherUserId), - }, + action: 'view_room', + room_id: cli.getRooms()[0].roomId, + should_peek: false, }); - } else if (request.channel.deviceId && request.verifier) { - // show to_device verifications in dialog still - const IncomingSasDialog = sdk.getComponent("views.dialogs.IncomingSasDialog"); - Modal.createTrackedDialog('Incoming Verification', '', IncomingSasDialog, { - verifier: request.verifier, - }, null, /* priority = */ false, /* static = */ true); } + await request.accept(); + dis.dispatch({ + action: "set_right_panel_phase", + phase: RIGHT_PANEL_PHASES.EncryptionPanel, + refireParams: { + verificationRequest: request, + member: cli.getUser(request.otherUserId), + }, + }); + // } else if (request.channel.deviceId && request.verifier) { + // // show to_device verifications in dialog still + // const IncomingSasDialog = sdk.getComponent("views.dialogs.IncomingSasDialog"); + // Modal.createTrackedDialog('Incoming Verification', '', IncomingSasDialog, { + // verifier: request.verifier, + // }, null, /* priority = */ false, /* static = */ true); + // } } catch (err) { console.error(err.message); } From 049a6d2064605c521e53fe91f19b3e86e4bd3976 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Sun, 2 Feb 2020 10:25:05 +0100 Subject: [PATCH 2/4] hide toast when request is accepted if this is a .request > .ready request, dismissing when in .ready is what we want, as that is how you accept the request if this is a .start request, we shouldn't dismiss so only add .ready to the phases to hide the toast, not .started --- 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 0c5d29ebe6..a5a26f7ddb 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.done || request.cancelled || request.observeOnly) { + if (request.ready || request.done || request.cancelled || request.observeOnly) { ToastStore.sharedInstance().dismissToast(this.props.toastKey); } }; From 1a5bed5a105f1db0bd219e52983fb03ff65ad704 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 31 Jan 2020 17:16:27 +0100 Subject: [PATCH 3/4] open a to_device request in a modal instead of the right panel 1st room --- .../views/toasts/VerificationRequestToast.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/views/toasts/VerificationRequestToast.js b/src/components/views/toasts/VerificationRequestToast.js index a5a26f7ddb..92402c3f98 100644 --- a/src/components/views/toasts/VerificationRequestToast.js +++ b/src/components/views/toasts/VerificationRequestToast.js @@ -78,28 +78,28 @@ export default class VerificationRequestToast extends React.PureComponent { // no room id for to_device requests const cli = MatrixClientPeg.get(); try { + await request.accept(); if (request.channel.roomId) { dis.dispatch({ action: 'view_room', room_id: request.channel.roomId, should_peek: false, }); - } else { dis.dispatch({ - action: 'view_room', - room_id: cli.getRooms()[0].roomId, - should_peek: false, + action: "set_right_panel_phase", + phase: RIGHT_PANEL_PHASES.EncryptionPanel, + refireParams: { + verificationRequest: request, + member: cli.getUser(request.otherUserId), + }, }); - } - await request.accept(); - dis.dispatch({ - action: "set_right_panel_phase", - phase: RIGHT_PANEL_PHASES.EncryptionPanel, - refireParams: { + } else { + const VerificationRequestDialog = sdk.getComponent("views.dialogs.VerificationRequestDialog"); + Modal.createTrackedDialog('Incoming Verification', '', VerificationRequestDialog, { verificationRequest: request, - member: cli.getUser(request.otherUserId), - }, - }); + }, null, /* priority = */ false, /* static = */ true); + } + // } else if (request.channel.deviceId && request.verifier) { // // show to_device verifications in dialog still // const IncomingSasDialog = sdk.getComponent("views.dialogs.IncomingSasDialog"); From 1ff1575b427dec63eda52d0ed586f4338dad340e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 10 Feb 2020 16:59:47 +0100 Subject: [PATCH 4/4] remove dead code --- src/components/views/toasts/VerificationRequestToast.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/components/views/toasts/VerificationRequestToast.js b/src/components/views/toasts/VerificationRequestToast.js index 92402c3f98..a831505a05 100644 --- a/src/components/views/toasts/VerificationRequestToast.js +++ b/src/components/views/toasts/VerificationRequestToast.js @@ -99,14 +99,6 @@ export default class VerificationRequestToast extends React.PureComponent { verificationRequest: request, }, null, /* priority = */ false, /* static = */ true); } - - // } else if (request.channel.deviceId && request.verifier) { - // // show to_device verifications in dialog still - // const IncomingSasDialog = sdk.getComponent("views.dialogs.IncomingSasDialog"); - // Modal.createTrackedDialog('Incoming Verification', '', IncomingSasDialog, { - // verifier: request.verifier, - // }, null, /* priority = */ false, /* static = */ true); - // } } catch (err) { console.error(err.message); }