File tree Expand file tree Collapse file tree
src/components/structures Expand file tree Collapse file tree Original file line number Diff line number Diff 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" ) ;
You can’t perform that action at this time.
0 commit comments