From 2d772eaaa8dfe6a8aeba9a67b50fafd2c74c0c0c Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 14 Apr 2016 11:12:15 +0200 Subject: Debounce heartbeat ajax calls to lower the number of requests fixes #22397 --- core/js/js.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'core/js/js.js') diff --git a/core/js/js.js b/core/js/js.js index 598e0dcd185..802b5de7e18 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1498,9 +1498,15 @@ function initCore() { interval = maxInterval; } var url = OC.generateUrl('/heartbeat'); - setInterval(function(){ - $.post(url); - }, interval * 1000); + var heartBeatTimeout = null; + var heartBeat = function() { + clearTimeout(heartBeatTimeout); + heartBeatTimeout = setInterval(function() { + $.post(url); + }, interval * 1000); + }; + $(document).ajaxComplete(heartBeat); + heartBeat(); } // session heartbeat (defaults to enabled) -- cgit v1.2.3