desktop support to modify selected files

This commit is contained in:
Igor Katson 2024-03-30 20:28:47 +00:00
parent dd53eda662
commit c6d3a972c4
2 changed files with 22 additions and 4 deletions

View file

@ -18,7 +18,7 @@ interface InvokeErrorResponse {
}
function errorToUIError(
path: string
path: string,
): (e: InvokeErrorResponse) => Promise<never> {
return (e: InvokeErrorResponse) => {
console.log(e);
@ -35,11 +35,11 @@ function errorToUIError(
export async function invokeAPI<Response>(
name: string,
params?: InvokeArgs
params?: InvokeArgs,
): Promise<Response> {
console.log("invoking", name, params);
const result = await invoke<Response>(name, params).catch(
errorToUIError(name)
errorToUIError(name),
);
console.log(result);
return result;
@ -96,7 +96,7 @@ export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => {
{
contents,
opts: opts ?? {},
}
},
);
}
return await invokeAPI<AddTorrentResponse>("torrent_create_from_url", {
@ -104,6 +104,12 @@ export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => {
opts: opts ?? {},
});
},
updateOnlyFiles: function (id, files): Promise<void> {
return invokeAPI<void>("torrent_action_configure", {
id: id,
onlyFiles: files,
});
},
pause: function (id: number): Promise<void> {
return invokeAPI<void>("torrent_action_pause", { id });
},