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 <thomas@piccirello.com>

PR #21689.
This commit is contained in:
Thomas Piccirello 2024-10-27 23:06:52 -07:00 committed by GitHub
parent e0e61ffd02
commit be3eefd8de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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