Skip to content

Commit 65f14c7

Browse files
committed
Stop random rooms appearing when switching network
in the public room directory
1 parent 864ba52 commit 65f14c7

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎src/components/structures/RoomDirectory.js‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,21 @@ module.exports = React.createClass({
9999

100100
const my_filter_string = this.filterString;
101101
const my_server = this.state.roomServer;
102+
// remember the next batch token when we sent the request
103+
// too. If it's changed, appending to the list will corrupt it.
104+
const my_next_batch = this.nextBatch;
102105
const opts = {limit: 20};
103106
if (my_server != MatrixClientPeg.getHomeServerName()) {
104107
opts.server = my_server;
105108
}
106109
if (this.nextBatch) opts.since = this.nextBatch;
107110
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ;
108111
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
109-
if (my_filter_string != this.filterString || my_server != this.state.roomServer) {
112+
if (
113+
my_filter_string != this.filterString ||
114+
my_server != this.state.roomServer ||
115+
my_next_batch != this.nextBatch)
116+
{
110117
// if the filter or server has changed since this request was sent,
111118
// throw away the result (don't even clear the busy flag
112119
// since we must still have a request in flight)
@@ -121,7 +128,11 @@ module.exports = React.createClass({
121128
});
122129
return Boolean(data.next_batch);
123130
}, (err) => {
124-
if (my_filter_string != this.filterString || my_server != this.state.roomServer) {
131+
if (
132+
my_filter_string != this.filterString ||
133+
my_server != this.state.roomServer ||
134+
my_next_batch != this.nextBatch)
135+
{
125136
// as above: we don't care about errors for old
126137
// requests either
127138
return;

0 commit comments

Comments
 (0)