Skip to content

Commit

Permalink
WebUI: migrate to fetch API
Browse files Browse the repository at this point in the history
This is the final part of it.

PR qbittorrent#22072.
  • Loading branch information
Chocobo1 authored Dec 29, 2024
1 parent e740a42 commit 9c0475e
Show file tree
Hide file tree
Showing 15 changed files with 626 additions and 551 deletions.
10 changes: 7 additions & 3 deletions src/webui/www/private/rename_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@
}
setupTable(selectedRows);
};
fileRenamer.onRenameError = (err, row) => {
if (err.xhr.status === 409)
fileRenamer.onRenameError = (response, row) => {
if (response.status === 409)
$("rename_error").textContent = `QBT_TR(Rename failed: file or folder already exists)QBT_TR[CONTEXT=PropertiesWidget] \`${row.renamed}\``;
};
$("renameOptions").addEventListener("change", (e) => {
Expand Down Expand Up @@ -379,7 +379,11 @@
};

const setupTable = (selectedRows) => {
fetch(new URI("api/v2/torrents/files").setData("hash", data.hash), {
const url = new URL("api/v2/torrents/files", window.location);
url.search = new URLSearchParams({
hash: data.hash
});
fetch(url, {
method: "GET",
cache: "no-store"
})
Expand Down
6 changes: 5 additions & 1 deletion src/webui/www/private/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,11 @@ window.addEventListener("DOMContentLoaded", () => {
let syncRequestInProgress = false;
const syncMainData = () => {
syncRequestInProgress = true;
fetch(new URI("api/v2/sync/maindata").setData("rid", syncMainDataLastResponseId), {
const url = new URL("api/v2/sync/maindata", window.location);
url.search = new URLSearchParams({
rid: syncMainDataLastResponseId
});
fetch(url, {
method: "GET",
cache: "no-store"
})
Expand Down
Loading

0 comments on commit 9c0475e

Please sign in to comment.