Wait a bit before sending filter requests
avoid hammering the server with requests for each keystroke
This commit is contained in:
parent
6d332256b5
commit
2fdec51a5b
1 changed files with 13 additions and 1 deletions
|
@ -66,6 +66,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
this.nextBatch = null;
|
this.nextBatch = null;
|
||||||
this.filterString = null;
|
this.filterString = null;
|
||||||
|
this.filterTimeout = null;
|
||||||
|
|
||||||
// dis.dispatch({
|
// dis.dispatch({
|
||||||
// action: 'ui_opacity',
|
// action: 'ui_opacity',
|
||||||
|
@ -209,7 +210,18 @@ module.exports = React.createClass({
|
||||||
this.showRoomAlias(alias);
|
this.showRoomAlias(alias);
|
||||||
} else {
|
} else {
|
||||||
this.filterString = alias || null;
|
this.filterString = alias || null;
|
||||||
this.refreshRoomList();
|
|
||||||
|
// don't send the request for a little bit,
|
||||||
|
// no point hammering the server with a
|
||||||
|
// request for every keystroke, let the
|
||||||
|
// user finish typing.
|
||||||
|
if (this.filterTimeout) {
|
||||||
|
clearTimeout(this.filterTimeout);
|
||||||
|
}
|
||||||
|
this.filterTimeout = setTimeout(() => {
|
||||||
|
this.filterTimeout = null;
|
||||||
|
this.refreshRoomList();
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue