Stop random rooms appearing when switching network

in the public room directory
This commit is contained in:
David Baker 2016-09-28 14:18:40 +01:00
parent 864ba52bc5
commit 65f14c7d21

View File

@ -99,6 +99,9 @@ module.exports = React.createClass({
const my_filter_string = this.filterString; const my_filter_string = this.filterString;
const my_server = this.state.roomServer; const my_server = this.state.roomServer;
// remember the next batch token when we sent the request
// too. If it's changed, appending to the list will corrupt it.
const my_next_batch = this.nextBatch;
const opts = {limit: 20}; const opts = {limit: 20};
if (my_server != MatrixClientPeg.getHomeServerName()) { if (my_server != MatrixClientPeg.getHomeServerName()) {
opts.server = my_server; opts.server = my_server;
@ -106,7 +109,11 @@ module.exports = React.createClass({
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 || my_server != this.state.roomServer) { if (
my_filter_string != this.filterString ||
my_server != this.state.roomServer ||
my_next_batch != this.nextBatch)
{
// if the filter or server 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)
@ -121,7 +128,11 @@ module.exports = React.createClass({
}); });
return Boolean(data.next_batch); return Boolean(data.next_batch);
}, (err) => { }, (err) => {
if (my_filter_string != this.filterString || my_server != this.state.roomServer) { if (
my_filter_string != this.filterString ||
my_server != this.state.roomServer ||
my_next_batch != this.nextBatch)
{
// 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;