mirror of https://github.com/vector-im/riot-web
Merge pull request #4556 from vector-im/rav/homepage_unmounted_guard
Give HomePage an unmounted guardpull/4557/head
commit
d25b441add
|
@ -52,6 +52,8 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
this._unmounted = false;
|
||||||
|
|
||||||
if (this.props.teamToken && this.props.teamServerUrl) {
|
if (this.props.teamToken && this.props.teamServerUrl) {
|
||||||
this.setState({
|
this.setState({
|
||||||
iframeSrc: `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`
|
iframeSrc: `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`
|
||||||
|
@ -67,9 +69,14 @@ module.exports = React.createClass({
|
||||||
request(
|
request(
|
||||||
{ method: "GET", url: src },
|
{ method: "GET", url: src },
|
||||||
(err, response, body) => {
|
(err, response, body) => {
|
||||||
|
if (this._unmounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (err || response.status < 200 || response.status >= 300) {
|
if (err || response.status < 200 || response.status >= 300) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.setState({ page: "Couldn't load home page" });
|
this.setState({ page: "Couldn't load home page" });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
body = body.replace(/_t\(['"]([\s\S]*?)['"]\)/mg, (match, g1)=>this.translate(g1));
|
body = body.replace(/_t\(['"]([\s\S]*?)['"]\)/mg, (match, g1)=>this.translate(g1));
|
||||||
|
@ -79,6 +86,10 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
this._unmounted = true;
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.state.iframeSrc) {
|
if (this.state.iframeSrc) {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue