From 41b6a5edbc3dadaf1374c235b0ba999c7e88ef99 Mon Sep 17 00:00:00 2001 From: mzzsfy Date: Thu, 4 Jan 2024 11:43:26 +0800 Subject: [PATCH] Improve the problem of lagging or even OOM caused by reactivation after hanging in the background for a long time --- internal/static/js/app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/static/js/app.js b/internal/static/js/app.js index 72ba5b2c..b7c34491 100644 --- a/internal/static/js/app.js +++ b/internal/static/js/app.js @@ -67,15 +67,18 @@ const connect = () => { timerange = val; updatePlots(); }); + setInterval(() => { + if (paused || ws.readyState !== WebSocket.OPEN) { + return + } + updatePlots(PlotsDef.events); + }, 1000) initDone = true; - return; - } - - stats.pushData(data); - if (paused) { + stats.pushData(data); + updatePlots(PlotsDef.events); return } - updatePlots(PlotsDef.events); + stats.pushData(data); } } @@ -139,7 +142,7 @@ theme.updateThemeMode(); $('#color_theme_sw').change(() => { const themeMode = theme.getThemeMode(); const newTheme = themeMode === "dark" && "light" || "dark"; - localStorage.setItem("theme-mode", newTheme); + localStorage.setItem("theme-mode", newTheme); theme.updateThemeMode(); updatePlotsLayout(); });