diff --git a/src/webui/www/private/addtorrent.html b/src/webui/www/private/addtorrent.html index dd5dc514e..23df8c8fa 100644 --- a/src/webui/www/private/addtorrent.html +++ b/src/webui/www/private/addtorrent.html @@ -195,10 +195,17 @@ - + + + + + + + + diff --git a/src/webui/www/private/scripts/addtorrent.js b/src/webui/www/private/scripts/addtorrent.js index 3addf2750..c2979265e 100644 --- a/src/webui/www/private/scripts/addtorrent.js +++ b/src/webui/www/private/scripts/addtorrent.js @@ -43,13 +43,21 @@ window.qBittorrent.AddTorrent ??= (() => { let windowId = ""; let source = ""; + const LocalPreferences = new window.qBittorrent.LocalPreferences.LocalPreferences(); + const getCategories = () => { + const defaultCategory = LocalPreferences.get("add_torrent_default_category", ""); + const categorySelect = document.getElementById("categorySelect"); for (const name of window.parent.qBittorrent.Client.categoryMap.keys()) { const option = document.createElement("option"); option.value = name; option.textContent = name; - document.getElementById("categorySelect").appendChild(option); + option.selected = name === defaultCategory; + categorySelect.appendChild(option); } + + if (defaultCategory !== "") + changeCategorySelect(categorySelect); }; const getTags = () => { @@ -299,6 +307,13 @@ window.qBittorrent.AddTorrent ??= (() => { document.getElementById("loadingSpinner").style.display = "block"; + if (document.getElementById("setDefaultCategory").checked) { + const category = document.getElementById("category").value.trim(); + if (category.length === 0) + LocalPreferences.remove("add_torrent_default_category"); + else + LocalPreferences.set("add_torrent_default_category", category); + } }; window.addEventListener("load", async (event) => {