From f851f976e7e82017cc02955c3adf758664d85ccc Mon Sep 17 00:00:00 2001 From: David Baker Date: Sat, 25 Jan 2020 21:26:43 +0000 Subject: [PATCH 1/2] Stop rogue verification toast if you verify during login Fixes https://github.com/vector-im/riot-web/issues/12057 --- src/components/structures/ToastContainer.js | 2 -- src/components/views/toasts/VerificationRequestToast.js | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/structures/ToastContainer.js b/src/components/structures/ToastContainer.js index 8a05f62e61..298c40e825 100644 --- a/src/components/structures/ToastContainer.js +++ b/src/components/structures/ToastContainer.js @@ -23,9 +23,7 @@ export default class ToastContainer extends React.Component { constructor() { super(); this.state = {toasts: ToastStore.sharedInstance().getToasts()}; - } - componentDidMount() { ToastStore.sharedInstance().on('update', this._onToastStoreUpdate); } diff --git a/src/components/views/toasts/VerificationRequestToast.js b/src/components/views/toasts/VerificationRequestToast.js index f912984486..b2d1aaf59d 100644 --- a/src/components/views/toasts/VerificationRequestToast.js +++ b/src/components/views/toasts/VerificationRequestToast.js @@ -39,6 +39,13 @@ export default class VerificationRequestToast extends React.PureComponent { this.setState({counter}); }, 1000); request.on("change", this._checkRequestIsPending); + // We should probably have a separate class managing the active verification toasts, + // rather than monitoring this in the toast component itself, since we'll get problems + // like the toasdt not going away when the verification is cancelled unless it's the + // one on the top (ie. the one that's mounted). + // As a quick & dirty fix, check the toast is still relevant when it mounts (this prevents + // a toast hanging around after logging in if you did a verification as part of login). + this._checkRequestIsPending(); } componentWillUnmount() { From 086e43e58469e7dba0fb2443b241ca1f68f2fe17 Mon Sep 17 00:00:00 2001 From: David Baker Date: Sat, 25 Jan 2020 21:30:42 +0000 Subject: [PATCH 2/2] comments ftw --- src/components/structures/ToastContainer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/ToastContainer.js b/src/components/structures/ToastContainer.js index 298c40e825..283fbdd96a 100644 --- a/src/components/structures/ToastContainer.js +++ b/src/components/structures/ToastContainer.js @@ -24,6 +24,10 @@ export default class ToastContainer extends React.Component { super(); this.state = {toasts: ToastStore.sharedInstance().getToasts()}; + // Start listening here rather than in componentDidMount because + // toasts may dismiss themselves in their didMount if they find + // they're already irrelevant by the time they're mounted, and + // our own componentDidMount is too late. ToastStore.sharedInstance().on('update', this._onToastStoreUpdate); }