mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 17:23:07 -07:00
WebUI: Add 'Confirm torrent recheck' option
This PR adds setting & confirmation dialog for torrent recheck. Closes #19557. PR #21348.
This commit is contained in:
parent
183c7c75b1
commit
c3224459db
7 changed files with 136 additions and 24 deletions
|
@ -48,14 +48,24 @@ window.qBittorrent.Dialog ??= (() => {
|
|||
|
||||
const deepFreeze = (obj) => {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#examples
|
||||
// accounts for circular refs
|
||||
const frozen = new WeakSet();
|
||||
const deepFreezeSafe = (obj) => {
|
||||
if (frozen.has(obj))
|
||||
return;
|
||||
|
||||
const keys = Reflect.ownKeys(obj);
|
||||
for (const key of keys) {
|
||||
const value = obj[key];
|
||||
if ((value && (typeof value === "object")) || (typeof value === "function"))
|
||||
deepFreeze(value);
|
||||
}
|
||||
Object.freeze(obj);
|
||||
frozen.add(obj);
|
||||
|
||||
const keys = Reflect.ownKeys(obj);
|
||||
for (const key of keys) {
|
||||
const value = obj[key];
|
||||
if ((value && (typeof value === "object")) || (typeof value === "function"))
|
||||
deepFreezeSafe(value);
|
||||
}
|
||||
Object.freeze(obj);
|
||||
};
|
||||
|
||||
deepFreezeSafe(obj);
|
||||
};
|
||||
|
||||
const baseModalOptions = Object.assign(Object.create(null), {
|
||||
|
@ -76,7 +86,11 @@ window.qBittorrent.Dialog ??= (() => {
|
|||
left: 5
|
||||
},
|
||||
resizable: true,
|
||||
width: 480
|
||||
width: 480,
|
||||
onCloseComplete: function() {
|
||||
// make sure overlay is properly hidden upon modal closing
|
||||
document.getElementById("modalOverlay").style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
deepFreeze(baseModalOptions);
|
||||
|
@ -541,15 +555,31 @@ const initializeWindows = function() {
|
|||
|
||||
recheckFN = function() {
|
||||
const hashes = torrentsTable.selectedRowsIds();
|
||||
if (hashes.length) {
|
||||
new Request({
|
||||
url: "api/v2/torrents/recheck",
|
||||
method: "post",
|
||||
data: {
|
||||
hashes: hashes.join("|"),
|
||||
}
|
||||
}).send();
|
||||
updateMainData();
|
||||
if (hashes.length > 0) {
|
||||
if (window.qBittorrent.Cache.preferences.get().confirm_torrent_recheck) {
|
||||
new MochaUI.Modal({
|
||||
...window.qBittorrent.Dialog.baseModalOptions,
|
||||
id: "confirmRecheckDialog",
|
||||
title: "QBT_TR(Recheck confirmation)QBT_TR[CONTEXT=confirmRecheckDialog]",
|
||||
data: { hashes: hashes },
|
||||
contentURL: "views/confirmRecheck.html"
|
||||
});
|
||||
}
|
||||
else {
|
||||
new Request({
|
||||
url: "api/v2/torrents/recheck",
|
||||
method: "post",
|
||||
data: {
|
||||
"hashes": hashes.join("|"),
|
||||
},
|
||||
onSuccess: function() {
|
||||
updateMainData();
|
||||
},
|
||||
onFailure: function() {
|
||||
alert("QBT_TR(Unable to recheck torrents.)QBT_TR[CONTEXT=HttpServer]");
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue