From 001740db3fed614204be7e950ddb95c4df1f0334 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 1 Feb 2019 18:35:12 +0100 Subject: [PATCH] Decrease ACP search frequency and ignore control characters The search still yields quite a few requests, but this is fine considering that it is (a) limited to the admin panel and (b) having faster results is a worthy trade off. --- wcfsetup/install/files/acp/js/WCF.ACP.js | 2 ++ wcfsetup/install/files/js/WCF.js | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 6e246add6d..d48e7c392b 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1678,6 +1678,8 @@ WCF.ACP.Category.Collapsible = WCF.Collapsible.SimpleRemote.extend({ * @see WCF.Search.Base */ WCF.ACP.Search = WCF.Search.Base.extend({ + _delay: 250, + /** * name of the selected search provider * @var string diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 66d6682d3b..c223d5f3cb 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -4101,6 +4101,11 @@ WCF.Search.Base = Class.extend({ */ _itemIndex: -1, + /** + * @var string + */ + _lastValue: '', + /** * result list * @var jQuery @@ -4156,6 +4161,7 @@ WCF.Search.Base = Class.extend({ this._caretAt = -1; this._delay = 0; this._excludedSearchValues = []; + this._lastValue = ''; if (excludedSearchValues) { this._excludedSearchValues = excludedSearchValues; } @@ -4257,6 +4263,12 @@ WCF.Search.Base = Class.extend({ this._clearList(false); } else if ($content.length >= this._triggerLength) { + if (this._lastValue === $content) { + return; + } + + this._lastValue = $content; + var $parameters = { data: { excludedSearchValues: this._excludedSearchValues, -- 2.20.1