From d17b17c2e3fbd67e4c42945903b4328ea4200b95 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 3 Feb 2021 12:14:05 +0100 Subject: [PATCH] Better kanban throttle --- www/kanban/inner.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/www/kanban/inner.js b/www/kanban/inner.js index 036a563b0..d32042780 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -133,13 +133,24 @@ define([ return tags; }; - var updateBoards = Util.throttle(function (framework, kanban, boards) { + var addEditItemButton = function () {}; + + var now = function () { return +new Date(); }; + var _lastUpdate = 0; + var _updateBoards = function (framework, kanban, boards) { + _lastUpdate = now(); kanban.setBoards(Util.clone(boards)); kanban.inEditMode = false; addEditItemButton(framework, kanban); - }, 500); + }; + var _updateBoardsThrottle = Util.throttle(_updateBoards, 500); + var updateBoards = function (framework, kanban, boards) { + if ((now() - _lastUpdate) > 5000) { + _updateBoards(framework, kanban, boards); + } + _updateBoardsThrottle(); + }; - var addEditItemButton = function () {}; var onRemoteChange = Util.mkEvent(); var editModal; var PROPERTIES = ['title', 'body', 'tags', 'color'];