mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-04 13:15:58 +03:00
Give Login an unmounted guard
This commit is contained in:
parent
3e93930dcc
commit
67372d4fed
1 changed files with 12 additions and 1 deletions
|
@ -72,9 +72,14 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
this._unmounted = false;
|
||||||
this._initLoginLogic();
|
this._initLoginLogic();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
this._unmounted = true;
|
||||||
|
},
|
||||||
|
|
||||||
onPasswordLogin: function(username, phoneCountry, phoneNumber, password) {
|
onPasswordLogin: function(username, phoneCountry, phoneNumber, password) {
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: true,
|
busy: true,
|
||||||
|
@ -87,6 +92,9 @@ module.exports = React.createClass({
|
||||||
).then((data) => {
|
).then((data) => {
|
||||||
this.props.onLoggedIn(data);
|
this.props.onLoggedIn(data);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
|
if(this._unmounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let errorText;
|
let errorText;
|
||||||
|
|
||||||
// Some error strings only apply for logging in
|
// Some error strings only apply for logging in
|
||||||
|
@ -109,8 +117,11 @@ module.exports = React.createClass({
|
||||||
loginIncorrect: error.httpStatus === 401 || error.httpStatus == 403,
|
loginIncorrect: error.httpStatus === 401 || error.httpStatus == 403,
|
||||||
});
|
});
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
if(this._unmounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: false
|
busy: false,
|
||||||
});
|
});
|
||||||
}).done();
|
}).done();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue