Clear properties panel when torrent no longer selected

This commit is contained in:
Thomas Piccirello 2024-10-12 11:45:10 -07:00
parent 25dbea1388
commit f4764d6145
No known key found for this signature in database
6 changed files with 61 additions and 10 deletions

View file

@ -229,32 +229,63 @@ window.addEventListener("DOMContentLoaded", () => {
buildLogTab();
MochaUI.initializeTabs("mainWindowTabsList");
const handleFilterSelectionChange = function(prevSelectedTorrent, currSelectedTorrent) {
// clear properties panels when filter changes (e.g. selected torrent is no longer visible)
if (prevSelectedTorrent !== currSelectedTorrent) {
window.qBittorrent.PropGeneral.clear();
window.qBittorrent.PropTrackers.clear();
window.qBittorrent.PropPeers.clear();
window.qBittorrent.PropWebseeds.clear();
window.qBittorrent.PropFiles.clear();
}
};
setStatusFilter = function(name) {
const currentHash = torrentsTable.getCurrentTorrentID();
LocalPreferences.set("selected_filter", name);
selectedStatus = name;
highlightSelectedStatus();
updateMainData();
const newHash = torrentsTable.getCurrentTorrentID();
handleFilterSelectionChange(currentHash, newHash);
};
setCategoryFilter = function(hash) {
const currentHash = torrentsTable.getCurrentTorrentID();
LocalPreferences.set("selected_category", hash);
selectedCategory = Number(hash);
highlightSelectedCategory();
updateMainData();
const newHash = torrentsTable.getCurrentTorrentID();
handleFilterSelectionChange(currentHash, newHash);
};
setTagFilter = function(hash) {
const currentHash = torrentsTable.getCurrentTorrentID();
LocalPreferences.set("selected_tag", hash);
selectedTag = Number(hash);
highlightSelectedTag();
updateMainData();
const newHash = torrentsTable.getCurrentTorrentID();
handleFilterSelectionChange(currentHash, newHash);
};
setTrackerFilter = function(hash) {
const currentHash = torrentsTable.getCurrentTorrentID();
LocalPreferences.set("selected_tracker", hash);
selectedTracker = Number(hash);
highlightSelectedTracker();
updateMainData();
const newHash = torrentsTable.getCurrentTorrentID();
handleFilterSelectionChange(currentHash, newHash);
};
toggleFilterDisplay = function(filterListID) {

View file

@ -42,7 +42,8 @@ window.qBittorrent.PropFiles ??= (() => {
updateData: updateData,
collapseIconClicked: collapseIconClicked,
expandFolder: expandFolder,
collapseFolder: collapseFolder
collapseFolder: collapseFolder,
clear: clear
};
};
@ -343,7 +344,6 @@ window.qBittorrent.PropFiles ??= (() => {
if (new_hash === "") {
torrentFilesTable.clear();
clearTimeout(loadTorrentFilesDataTimer);
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(5000);
return;
}
let loadedNewTorrent = false;
@ -764,6 +764,10 @@ window.qBittorrent.PropFiles ??= (() => {
});
};
const clear = function() {
torrentFilesTable.clear();
};
return exports();
})();
Object.freeze(window.qBittorrent.PropFiles);

View file

@ -32,7 +32,8 @@ window.qBittorrent ??= {};
window.qBittorrent.PropGeneral ??= (() => {
const exports = () => {
return {
updateData: updateData
updateData: updateData,
clear: clear
};
};
@ -83,7 +84,6 @@ window.qBittorrent.PropGeneral ??= (() => {
if (current_id === "") {
clearData();
clearTimeout(loadTorrentDataTimer);
loadTorrentDataTimer = loadTorrentData.delay(5000);
return;
}
const url = new URI("api/v2/torrents/properties?hash=" + current_id);
@ -254,6 +254,10 @@ window.qBittorrent.PropGeneral ??= (() => {
loadTorrentData();
};
const clear = function() {
clearData();
};
return exports();
})();
Object.freeze(window.qBittorrent.PropGeneral);

View file

@ -32,7 +32,8 @@ window.qBittorrent ??= {};
window.qBittorrent.PropPeers ??= (() => {
const exports = () => {
return {
updateData: updateData
updateData: updateData,
clear: clear
};
};
@ -53,7 +54,6 @@ window.qBittorrent.PropPeers ??= (() => {
syncTorrentPeersLastResponseId = 0;
torrentPeersTable.clear();
clearTimeout(loadTorrentPeersTimer);
loadTorrentPeersTimer = loadTorrentPeersData.delay(window.qBittorrent.Client.getSyncMainDataInterval());
return;
}
const url = new URI("api/v2/sync/torrentPeers");
@ -112,6 +112,10 @@ window.qBittorrent.PropPeers ??= (() => {
loadTorrentPeersData();
};
const clear = function() {
torrentPeersTable.clear();
};
const torrentPeersContextMenu = new window.qBittorrent.ContextMenu.ContextMenu({
targets: "#torrentPeersTableDiv",
menu: "torrentPeersMenu",

View file

@ -32,7 +32,8 @@ window.qBittorrent ??= {};
window.qBittorrent.PropTrackers ??= (() => {
const exports = () => {
return {
updateData: updateData
updateData: updateData,
clear: clear
};
};
@ -51,7 +52,6 @@ window.qBittorrent.PropTrackers ??= (() => {
if (new_hash === "") {
torrentTrackersTable.clear();
clearTimeout(loadTrackersDataTimer);
loadTrackersDataTimer = loadTrackersData.delay(10000);
return;
}
if (new_hash !== current_hash) {
@ -227,6 +227,10 @@ window.qBittorrent.PropTrackers ??= (() => {
}).send();
};
const clear = function() {
torrentTrackersTable.clear();
};
new ClipboardJS("#CopyTrackerUrl", {
text: function(trigger) {
return torrentTrackersTable.selectedRowsIds().join("\n");

View file

@ -32,7 +32,8 @@ window.qBittorrent ??= {};
window.qBittorrent.PropWebseeds ??= (() => {
const exports = () => {
return {
updateData: updateData
updateData: updateData,
clear: clear
};
};
@ -51,7 +52,6 @@ window.qBittorrent.PropWebseeds ??= (() => {
if (new_hash === "") {
torrentWebseedsTable.clear();
clearTimeout(loadWebSeedsDataTimer);
loadWebSeedsDataTimer = loadWebSeedsData.delay(10000);
return;
}
if (new_hash !== current_hash) {
@ -204,6 +204,10 @@ window.qBittorrent.PropWebseeds ??= (() => {
}).send();
};
const clear = function() {
torrentWebseedsTable.clear();
};
new ClipboardJS("#CopyWebseedUrl", {
text: function(trigger) {
return torrentWebseedsTable.selectedRowsIds().join("\n");