Unmounted guard

This commit is contained in:
David Baker 2017-11-07 17:10:40 +00:00
parent ec560345c7
commit 10f15dfc56

View File

@ -97,6 +97,8 @@ export default React.createClass({
},
componentWillMount: function() {
this._unmounted = false;
const roomMembers = this.props.room.getJoinedMembers().map((m) => {
return m.userId;
});
@ -106,6 +108,8 @@ export default React.createClass({
devices: null,
});
MatrixClientPeg.get().downloadKeys(roomMembers, false).then((devices) => {
if (this._unmounted) return;
const unknownDevices = {};
// This is all devices in this room, so find the unknown ones.
Object.keys(devices).forEach((userId) => {
@ -133,6 +137,10 @@ export default React.createClass({
});
},
componentWillUnmount: function() {
this._unmounted = true;
},
render: function() {
if (this.state.devices === null) {
const Spinner = sdk.getComponent("elements.Spinner");