From 008b04f30973d2613f3a4f41cd845b69cb13af46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Hermida?= Date: Wed, 4 Jul 2018 09:53:46 +0200 Subject: [PATCH] Update debounce to random timeout --- app/coffee/modules/kanban/main.coffee | 3 ++- app/coffee/utils.coffee | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index 3953d252..eface736 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -345,7 +345,8 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi initializeSubscription: -> routingKey1 = "changes.project.#{@scope.projectId}.userstories" - @events.subscribe @scope, routingKey1, debounceLeading(500, (message) => + randomTimeout = taiga.randomInt(700, 1000) + @events.subscribe @scope, routingKey1, debounceLeading(randomTimeout, (message) => @.loadUserstories()) loadInitialData: -> diff --git a/app/coffee/utils.coffee b/app/coffee/utils.coffee index 85fce1bc..2b1e8372 100644 --- a/app/coffee/utils.coffee +++ b/app/coffee/utils.coffee @@ -266,6 +266,10 @@ getMatches = (string, regex, index) -> return matches +randomInt = (start, end) -> + interval = end - start + return start + Math.floor(Math.random()*(interval+1)) + taiga = @.taiga taiga.addClass = addClass taiga.nl2br = nl2br @@ -297,3 +301,4 @@ taiga.patch = patch taiga.getRandomDefaultColor = getRandomDefaultColor taiga.getDefaulColorList = getDefaulColorList taiga.getMatches = getMatches +taiga.randomInt = randomInt