]> source.dussan.org Git - nextcloud-server.git/commitdiff
replace setTimeout and clearTimeout handling by _.debounce
authorArthur Schiwon <blizzz@owncloud.com>
Tue, 13 May 2014 13:59:04 +0000 (15:59 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 2 Jun 2014 10:53:59 +0000 (12:53 +0200)
settings/js/users/filter.js

index 403e9c00c11a283d9b6916f0a632310752c06e3f..bd3473d0e4d98ff2c25c516d33208f6dcabd5c84 100644 (file)
@@ -41,14 +41,9 @@ UserManagementFilter.prototype.init = function() {
                //besides the keys, the value must have been changed compared to last
                //time
                if(valid && umf.oldVal !== umf.getPattern()) {
-                       clearTimeout(umf.thread);
-                       umf.thread = setTimeout(
-                               function() {
-                                       umf.run();
-                               },
-                               300
-                       );
+                       umf.run();
                }
+
                umf.oldVal = umf.getPattern();
        });
 };
@@ -57,12 +52,15 @@ UserManagementFilter.prototype.init = function() {
  * @brief the filter action needs to be done, here the accurate steps are being
  * taken care of
  */
-UserManagementFilter.prototype.run = function() {
-       this.userList.empty();
-       this.userList.update(GroupList.getCurrentGID());
-       this.groupList.empty();
-       this.groupList.update();
-};
+UserManagementFilter.prototype.run = _.debounce(function() {
+               console.log(this);
+               this.userList.empty();
+               this.userList.update(GroupList.getCurrentGID());
+               this.groupList.empty();
+               this.groupList.update();
+       },
+       300
+);
 
 /**
  * @brief returns the filter String
@@ -82,4 +80,4 @@ UserManagementFilter.prototype.addResetButton = function(button) {
                umf.filterInput.val('');
                umf.run();
        });
-};
\ No newline at end of file
+};