From 8f02ab2befb99b049fc51b3c6f09db417be7f2c7 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Tue, 16 Apr 2019 22:20:08 +0100 Subject: [PATCH] Fixed the TickerWidget making repeated calls --- Monitor/Pages/_Layout.cshtml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Monitor/Pages/_Layout.cshtml b/Monitor/Pages/_Layout.cshtml index 4d99b31..a4ab6fc 100644 --- a/Monitor/Pages/_Layout.cshtml +++ b/Monitor/Pages/_Layout.cshtml @@ -172,6 +172,13 @@ var errCount = []; var interval; var loadWidgets = function () { + // Clear exisitng interval to stop multiple attempts to load at the same time. + if (interval != null) + { + clearInterval(interval); + } + + // Load widgets $('[data-toggle="tooltip"]').tooltip(); $("#ticker-widgets").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/TickerWidgets', '', function (responseText, textStatus, XMLHttpRequest) { if (textStatus == 'error') { @@ -184,13 +191,15 @@ } else { errCount["TickerWidgets"] = 0; } + + // Reinstate the interval. + interval = setInterval(function () { loadWidgets(); }, 5000); }); }; $(document).ready(function () { errCount["TickerWidgets"] = 0; loadWidgets(); - interval = setInterval(function () { loadWidgets(); }, 5 * 1000); $('[data-toggle="tooltip"]').tooltip() $('.text-autocolor').autocolor(false);