parent
cc72f7ec24
commit
e177263d9f
|
@ -511,12 +511,11 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
if (DEBUG_SCROLL) console.log("sending search request");
|
if (DEBUG_SCROLL) console.log("sending search request");
|
||||||
|
|
||||||
var searchPromise = MatrixClientPeg.get().searchRoomEvents(
|
var searchPromise = MatrixClientPeg.get().searchRoomEvents({
|
||||||
{ filter: filter,
|
filter: filter,
|
||||||
term: term,
|
term: term,
|
||||||
});
|
});
|
||||||
this._handleSearchResult(searchPromise)
|
this._handleSearchResult(searchPromise).done();
|
||||||
.done();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_backPaginateSearch: function() {
|
_backPaginateSearch: function() {
|
||||||
|
@ -524,13 +523,15 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var searchPromise = MatrixClientPeg.get().backPaginateRoomEventsSearch(
|
var searchPromise = MatrixClientPeg.get().backPaginateRoomEventsSearch(
|
||||||
this.state.searchResults);
|
this.state.searchResults);
|
||||||
this._handleSearchResult(searchPromise)
|
this._handleSearchResult(searchPromise).done();
|
||||||
.done();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleSearchResult: function(searchPromise) {
|
_handleSearchResult: function(searchPromise) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var searchId = this.searchId;
|
|
||||||
|
// keep a record of the current search id, so that if the search terms
|
||||||
|
// change before we get a response, we can ignore the results.
|
||||||
|
var localSearchId = this.searchId;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
searchInProgress: true,
|
searchInProgress: true,
|
||||||
|
@ -538,7 +539,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
return searchPromise.then(function(results) {
|
return searchPromise.then(function(results) {
|
||||||
if (DEBUG_SCROLL) console.log("search complete");
|
if (DEBUG_SCROLL) console.log("search complete");
|
||||||
if (!self.state.searching || self.searchId != searchId) {
|
if (!self.state.searching || self.searchId != localSearchId) {
|
||||||
console.error("Discarding stale search results");
|
console.error("Discarding stale search results");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var searchStatus;
|
var searchStatus;
|
||||||
// don't display the search count until the search completes and
|
// don't display the search count until the search completes and
|
||||||
// gives us a non-null searchCount.
|
// gives us a valid (possibly zero) searchCount.
|
||||||
if (this.props.searchInfo && this.props.searchInfo.searchCount != null) {
|
if (this.props.searchInfo && this.props.searchInfo.searchCount != null) {
|
||||||
searchStatus = <div className="mx_RoomHeader_searchStatus"> (~{ this.props.searchInfo.searchCount } results)</div>;
|
searchStatus = <div className="mx_RoomHeader_searchStatus"> (~{ this.props.searchInfo.searchCount } results)</div>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue