Skip to content

Commit 6d33225

Browse files
committed
Ignore results of old requests
1 parent 2b6fbb0 commit 6d33225

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/components/structures/RoomDirectory.js‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,19 @@ module.exports = React.createClass({
9595
},
9696

9797
getMoreRooms: function() {
98+
const my_filter_string = this.filterString;
9899
const opts = {limit: 20};
99100
if (this.nextBatch) opts.since = this.nextBatch;
100-
if (this.filterString) opts.filter = { generic_search_term: this.filterString } ;
101+
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ;
101102
this.setState({loading: true});
102103
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
104+
if (my_filter_string != this.filterString) {
105+
// if the filter has changed since this request was sent,
106+
// throw away the result (don't even clear the busy flag
107+
// since we must still have a request in flight)
108+
return;
109+
}
110+
103111
this.nextBatch = data.next_batch;
104112
this.setState((s) => {
105113
s.publicRooms.push(...data.chunk);
@@ -108,6 +116,11 @@ module.exports = React.createClass({
108116
});
109117
return Boolean(data.next_batch);
110118
}, (err) => {
119+
if (my_filter_string != this.filterString) {
120+
// as above: we don't care about errors for old
121+
// requests either
122+
return;
123+
}
111124
this.setState({ loading: false });
112125
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
113126
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");

0 commit comments

Comments
 (0)