From be3eefd8de34d9b293d2718f26064ea674c2bd7c Mon Sep 17 00:00:00 2001 From: Thomas Piccirello <8296030+Piccirello@users.noreply.github.com> Date: Sun, 27 Oct 2024 23:06:52 -0700 Subject: [PATCH] WebUI: Fix displaying RSS panel on load The required JS may not yet be loaded, resulting in an error when calling `window.qBittorrent.Rss.init()`. Signed-off-by: Thomas Piccirello PR #21689. --- src/webui/www/private/scripts/client.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 7966befa7..e2c3771d3 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -155,6 +155,7 @@ let toggleFilterDisplay = function() {}; window.addEventListener("DOMContentLoaded", () => { let isSearchPanelLoaded = false; let isLogPanelLoaded = false; + let isRssPanelLoaded = false; const saveColumnSizes = function() { const filters_width = $("Filters").getSize().x; @@ -1274,6 +1275,16 @@ window.addEventListener("DOMContentLoaded", () => { let rssTabInitialized = false; return () => { + // we must wait until the panel is fully loaded before proceeding. + // this include's the panel's custom js, which is loaded via MochaUI.Panel's 'require' field. + // MochaUI loads these files asynchronously and thus all required libs may not be available immediately + if (!isRssPanelLoaded) { + setTimeout(() => { + showRssTab(); + }, 100); + return; + } + if (!rssTabInitialized) { window.qBittorrent.Rss.init(); rssTabInitialized = true; @@ -1374,6 +1385,9 @@ window.addEventListener("DOMContentLoaded", () => { }, loadMethod: "xhr", contentURL: "views/rss.html", + onContentLoaded: () => { + isRssPanelLoaded = true; + }, content: "", column: "rssTabColumn", height: null -- 2.11.4.GIT