Stop rogue verification toast if you verify during login

Fixes https://github.com/vector-im/riot-web/issues/12057
This commit is contained in:
David Baker 2020-01-25 21:26:43 +00:00
parent 9e38c62791
commit f851f976e7
2 changed files with 7 additions and 2 deletions

View file

@ -23,9 +23,7 @@ export default class ToastContainer extends React.Component {
constructor() { constructor() {
super(); super();
this.state = {toasts: ToastStore.sharedInstance().getToasts()}; this.state = {toasts: ToastStore.sharedInstance().getToasts()};
}
componentDidMount() {
ToastStore.sharedInstance().on('update', this._onToastStoreUpdate); ToastStore.sharedInstance().on('update', this._onToastStoreUpdate);
} }

View file

@ -39,6 +39,13 @@ export default class VerificationRequestToast extends React.PureComponent {
this.setState({counter}); this.setState({counter});
}, 1000); }, 1000);
request.on("change", this._checkRequestIsPending); 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() { componentWillUnmount() {