WebUI: fetch cached info early

The cached info doesn't need to wait until the DOM is loaded. They can be fetched far earlier.

PR #21830.
This commit is contained in:
Chocobo1 2024-11-16 15:34:35 +08:00 committed by GitHub
parent c9a55fce95
commit ede08f3845
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,6 +29,7 @@ window.qBittorrent ??= {};
window.qBittorrent.Client ??= (() => {
const exports = () => {
return {
setup: setup,
closeWindow: closeWindow,
closeFrameWindow: closeFrameWindow,
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) {