Possibility to change selected files after the fact

This commit is contained in:
Igor Katson 2024-03-30 20:05:12 +00:00
parent feae1789a9
commit 86d9d2c5f0
11 changed files with 186 additions and 52 deletions

View file

@ -16,17 +16,26 @@ const apiUrl =
const makeRequest = async (
method: string,
path: string,
data?: any
data?: any,
isJson?: boolean,
): Promise<any> => {
console.log(method, path);
const url = apiUrl + path;
const options: RequestInit = {
let options: RequestInit = {
method,
headers: {
Accept: "application/json",
},
body: data,
};
if (isJson) {
options.headers = {
Accept: "application/json",
"Content-Type": "application/json",
};
options.body = JSON.stringify(data);
} else {
options.body = data;
}
let error: ErrorDetails = {
method: method,
@ -100,6 +109,18 @@ export const API: RqbitAPI & { getVersion: () => Promise<string> } = {
return makeRequest("POST", url, data);
},
updateOnlyFiles: (index: number, files: number[]): Promise<void> => {
let url = `/torrents/${index}/update_only_files`;
return makeRequest(
"POST",
url,
{
only_files: files,
},
true,
);
},
pause: (index: number): Promise<void> => {
return makeRequest("POST", `/torrents/${index}/pause`);
},