From d2dd1bae135830f144f962a97fa246cc3ca3b260 Mon Sep 17 00:00:00 2001 From: Bruno Windels <brunow@matrix.org> Date: Thu, 7 Feb 2019 16:31:57 +0000 Subject: [PATCH] run search after you've stopped typing for 200ms instead of every 500ms --- src/components/structures/SearchBox.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/structures/SearchBox.js b/src/components/structures/SearchBox.js index fbcd9a7279..2f777c1163 100644 --- a/src/components/structures/SearchBox.js +++ b/src/components/structures/SearchBox.js @@ -21,7 +21,7 @@ import { _t } from '../../languageHandler'; import { KeyCode } from '../../Keyboard'; import sdk from '../../index'; import dis from '../../dispatcher'; -import rate_limited_func from '../../ratelimitedfunc'; +import { debounce } from 'lodash'; import AccessibleButton from '../../components/views/elements/AccessibleButton'; module.exports = React.createClass({ @@ -67,12 +67,9 @@ module.exports = React.createClass({ this.onSearch(); }, - onSearch: new rate_limited_func( - function() { - this.props.onSearch(this.refs.search.value); - }, - 500, - ), + onSearch: debounce(function() { + this.props.onSearch(this.refs.search.value); + }, 200, {trailing: true}), _onKeyDown: function(ev) { switch (ev.keyCode) {