mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
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
@ -98,15 +98,16 @@ module.exports = React.createClass({
|
||||
if (!MatrixClientPeg.get()) return q();
|
||||
|
||||
const my_filter_string = this.filterString;
|
||||
const my_server = this.state.roomServer;
|
||||
const opts = {limit: 20};
|
||||
if (this.state.roomServer != MatrixClientPeg.getHomeServerName()) {
|
||||
opts.server = this.state.roomServer;
|
||||
if (my_server != MatrixClientPeg.getHomeServerName()) {
|
||||
opts.server = my_server;
|
||||
}
|
||||
if (this.nextBatch) opts.since = this.nextBatch;
|
||||
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ;
|
||||
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
|
||||
if (my_filter_string != this.filterString) {
|
||||
// if the filter has changed since this request was sent,
|
||||
if (my_filter_string != this.filterString || my_server != this.state.roomServer) {
|
||||
// if the filter or server has changed since this request was sent,
|
||||
// throw away the result (don't even clear the busy flag
|
||||
// since we must still have a request in flight)
|
||||
return;
|
||||
@ -120,7 +121,7 @@ module.exports = React.createClass({
|
||||
});
|
||||
return Boolean(data.next_batch);
|
||||
}, (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
|
||||
// requests either
|
||||
return;
|
||||
@ -195,10 +196,22 @@ module.exports = React.createClass({
|
||||
},
|
||||
|
||||
onOptionChange: function(server, network) {
|
||||
// clear next batch so we don't try to load more rooms
|
||||
this.nextBatch = null;
|
||||
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,
|
||||
filterByNetwork: network,
|
||||
}, 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user