Fix spurious fill requests when switching networks
Ignore responses for old servers too, don't trigger a backfill request when we re-render before refresh. Also a few more comments.
This commit is contained in:
parent
85ea45a64a
commit
6ff1c30a4b
1 changed files with 18 additions and 5 deletions
|
@ -98,15 +98,16 @@ module.exports = React.createClass({
|
||||||
if (!MatrixClientPeg.get()) return q();
|
if (!MatrixClientPeg.get()) return q();
|
||||||
|
|
||||||
const my_filter_string = this.filterString;
|
const my_filter_string = this.filterString;
|
||||||
|
const my_server = this.state.roomServer;
|
||||||
const opts = {limit: 20};
|
const opts = {limit: 20};
|
||||||
if (this.state.roomServer != MatrixClientPeg.getHomeServerName()) {
|
if (my_server != MatrixClientPeg.getHomeServerName()) {
|
||||||
opts.server = this.state.roomServer;
|
opts.server = my_server;
|
||||||
}
|
}
|
||||||
if (this.nextBatch) opts.since = this.nextBatch;
|
if (this.nextBatch) opts.since = this.nextBatch;
|
||||||
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ;
|
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ;
|
||||||
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
|
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
|
||||||
if (my_filter_string != this.filterString) {
|
if (my_filter_string != this.filterString || my_server != this.state.roomServer) {
|
||||||
// if the filter has changed since this request was sent,
|
// if the filter or server has changed since this request was sent,
|
||||||
// throw away the result (don't even clear the busy flag
|
// throw away the result (don't even clear the busy flag
|
||||||
// since we must still have a request in flight)
|
// since we must still have a request in flight)
|
||||||
return;
|
return;
|
||||||
|
@ -120,7 +121,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
return Boolean(data.next_batch);
|
return Boolean(data.next_batch);
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
if (my_filter_string != this.filterString) {
|
if (my_filter_string != this.filterString || my_server != this.state.roomServer) {
|
||||||
// as above: we don't care about errors for old
|
// as above: we don't care about errors for old
|
||||||
// requests either
|
// requests either
|
||||||
return;
|
return;
|
||||||
|
@ -195,10 +196,22 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onOptionChange: function(server, network) {
|
onOptionChange: function(server, network) {
|
||||||
|
// clear next batch so we don't try to load more rooms
|
||||||
|
this.nextBatch = null;
|
||||||
this.setState({
|
this.setState({
|
||||||
|
// Clear the public rooms out here otherwise we needlessly
|
||||||
|
// spend time filtering lots of rooms when we're about to
|
||||||
|
// to clear the list anyway.
|
||||||
|
publicRooms: [],
|
||||||
roomServer: server,
|
roomServer: server,
|
||||||
filterByNetwork: network,
|
filterByNetwork: network,
|
||||||
}, this.refreshRoomList);
|
}, this.refreshRoomList);
|
||||||
|
// We also refresh the room list each time even though this
|
||||||
|
// filtering is client-side. It hopefully won't be client side
|
||||||
|
// for very long, and we may have fetched a thousand rooms to
|
||||||
|
// find the five gitter ones, at which point we do not want
|
||||||
|
// to render all those rooms when switching back to 'all networks'.
|
||||||
|
// Easiest to just blow away the state & re-fetch.
|
||||||
},
|
},
|
||||||
|
|
||||||
onFillRequest: function(backwards) {
|
onFillRequest: function(backwards) {
|
||||||
|
|
Loading…
Reference in a new issue