From a6ed5400b41ba3cdada35a0bf9787047a913780d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 13 Nov 2024 19:36:19 +0800 Subject: [PATCH] WebUI: fetch cached info early The cached info doesn't need to wait until the DOM is loaded. They can be fetched far earlier. --- src/webui/www/private/scripts/client.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 6373b4793..b6f51ab82 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -29,6 +29,7 @@ window.qBittorrent ??= {}; window.qBittorrent.Client ??= (() => { const exports = () => { return { + setup: setup, closeWindow: closeWindow, closeWindows: closeWindows, getSyncMainDataInterval: getSyncMainDataInterval, @@ -44,6 +45,13 @@ window.qBittorrent.Client ??= (() => { }; }; + const setup = () => { + // fetch various data and store it in memory + window.qBittorrent.Cache.buildInfo.init(); + window.qBittorrent.Cache.preferences.init(); + window.qBittorrent.Cache.qbtVersion.init(); + }; + const closeWindow = (windowID) => { const window = document.getElementById(windowID); if (!window) @@ -104,6 +112,8 @@ window.qBittorrent.Client ??= (() => { })(); Object.freeze(window.qBittorrent.Client); +window.qBittorrent.Client.setup(); + // TODO: move global functions/variables into some namespace/scope this.torrentsTable = new window.qBittorrent.DynamicTable.TorrentsTable(); @@ -1755,11 +1765,6 @@ window.addEventListener("DOMContentLoaded", () => { }); window.addEventListener("load", () => { - // fetch various data and store it in memory - window.qBittorrent.Cache.buildInfo.init(); - window.qBittorrent.Cache.preferences.init(); - window.qBittorrent.Cache.qbtVersion.init(); - // switch to previously used tab const previouslyUsedTab = LocalPreferences.get("selected_window_tab", "transfers"); switch (previouslyUsedTab) {