Skip to content

Commit b886215

Browse files
authored
Merge pull request element-hq#3958 from vector-im/rav/roomdirectory_unmounting
Fix some setState-after-unmount in roomdirectory
2 parents 4d60d44 + 86055bc commit b886215

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎src/components/structures/RoomDirectory.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = React.createClass({
6060
},
6161

6262
componentWillMount: function() {
63+
this._unmounted = false;
6364
this.nextBatch = null;
6465
this.filterTimeout = null;
6566
this.scrollPanel = null;
@@ -97,6 +98,10 @@ module.exports = React.createClass({
9798
// sideOpacity: 1.0,
9899
// middleOpacity: 1.0,
99100
// });
101+
if (this.filterTimeout) {
102+
clearTimeout(this.filterTimeout);
103+
}
104+
this._unmounted = true;
100105
},
101106

102107
refreshRoomList: function() {
@@ -139,6 +144,11 @@ module.exports = React.createClass({
139144
return;
140145
}
141146

147+
if (this._unmounted) {
148+
// if we've been unmounted, we don't care either.
149+
return;
150+
}
151+
142152
this.nextBatch = data.next_batch;
143153
this.setState((s) => {
144154
s.publicRooms.push(...data.chunk);
@@ -156,6 +166,12 @@ module.exports = React.createClass({
156166
// requests either
157167
return;
158168
}
169+
170+
if (this._unmounted) {
171+
// if we've been unmounted, we don't care either.
172+
return;
173+
}
174+
159175
this.setState({ loading: false });
160176
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
161177
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");

0 commit comments

Comments
 (0)