From 667ff00cf6ad96da8ede7d2bc42950a606a56912 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 10 Oct 2014 12:40:23 +0200 Subject: [PATCH] Fixing the bad debounces --- app/coffee/modules/backlog/filters.coffee | 4 ++-- app/coffee/modules/issues/list.coffee | 4 ++-- app/coffee/modules/search.coffee | 4 ++-- app/coffee/utils.coffee | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/coffee/modules/backlog/filters.coffee b/app/coffee/modules/backlog/filters.coffee index 778cf011..6ce39e8e 100644 --- a/app/coffee/modules/backlog/filters.coffee +++ b/app/coffee/modules/backlog/filters.coffee @@ -26,7 +26,7 @@ toggleText = @.taiga.toggleText scopeDefer = @.taiga.scopeDefer bindOnce = @.taiga.bindOnce groupBy = @.taiga.groupBy -debounce = @.taiga.debounce +debounceLeading = @.taiga.debounceLeading module = angular.module("taigaBacklog") @@ -130,7 +130,7 @@ BacklogFiltersDirective = ($log, $location) -> $ctrl.loadUserstories() - selectQFilter = debounce 400, (value) -> + selectQFilter = debounceLeading 100, (value) -> return if value is undefined if value.length == 0 $ctrl.replaceFilter("q", null) diff --git a/app/coffee/modules/issues/list.coffee b/app/coffee/modules/issues/list.coffee index fd06841a..179e39d1 100644 --- a/app/coffee/modules/issues/list.coffee +++ b/app/coffee/modules/issues/list.coffee @@ -27,7 +27,7 @@ toString = @.taiga.toString joinStr = @.taiga.joinStr groupBy = @.taiga.groupBy bindOnce = @.taiga.bindOnce -debounce = @.taiga.debounce +debounceLeading = @.taiga.debounceLeading startswith = @.taiga.startswith module = angular.module("taigaIssues") @@ -577,7 +577,7 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading) -> $scope.$on "filters:loaded", (ctx, filters) -> initializeSelectedFilters(filters) - selectQFilter = debounce 400, (value) -> + selectQFilter = debounceLeading 100, (value) -> return if value is undefined if value.length == 0 $ctrl.replaceFilter("q", null) diff --git a/app/coffee/modules/search.coffee b/app/coffee/modules/search.coffee index dee6d81a..fa5b390e 100644 --- a/app/coffee/modules/search.coffee +++ b/app/coffee/modules/search.coffee @@ -24,7 +24,7 @@ taiga = @.taiga groupBy = @.taiga.groupBy bindOnce = @.taiga.bindOnce mixOf = @.taiga.mixOf -debounce = @.taiga.debounce +debounceLeading = @.taiga.debounceLeading trim = @.taiga.trim module = angular.module("taigaSearch", []) @@ -63,7 +63,7 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin) # Search input watcher @scope.searchTerm = "" - loadSearchData = debounce(200, (t) => @.loadSearchData(t)) + loadSearchData = debounceLeading(100, (t) => @.loadSearchData(t)) @scope.$watch "searchTerm", (term) => if not term diff --git a/app/coffee/utils.coffee b/app/coffee/utils.coffee index f5dc5e11..b7150637 100644 --- a/app/coffee/utils.coffee +++ b/app/coffee/utils.coffee @@ -106,6 +106,9 @@ joinStr = (str, coll) -> debounce = (wait, func) -> return _.debounce(func, wait, {leading: true, trailing: false}) +debounceLeading = (wait, func) -> + return _.debounce(func, wait, {leading: false, trailing: true}) + startswith = (str1, str2) -> return _.str.startsWith(str1, str2) @@ -140,5 +143,6 @@ taiga.scopeDefer = scopeDefer taiga.toString = toString taiga.joinStr = joinStr taiga.debounce = debounce +taiga.debounceLeading = debounceLeading taiga.startswith = startswith taiga.sizeFormat = sizeFormat