Decrease ACP search frequency and ignore control characters
authorAlexander Ebert <ebert@woltlab.com>
Fri, 1 Feb 2019 17:35:12 +0000 (18:35 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 1 Feb 2019 17:35:12 +0000 (18:35 +0100)
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
wcfsetup/install/files/js/WCF.js

index 6e246add6de81ad962c53e5865b96235397fbcd5..d48e7c392b52f78419954e960b1be18f8c9ca70d 100644 (file)
@@ -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
index 66d6682d3b8f5098a71ad1c8fc911012e92a1049..c223d5f3cb383f0304be7421bffd5629d635b16c 100755 (executable)
@@ -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,