desktop support to modify selected files
This commit is contained in:
parent
dd53eda662
commit
c6d3a972c4
2 changed files with 22 additions and 4 deletions
|
|
@ -293,6 +293,17 @@ async fn torrent_action_start(
|
||||||
state.api()?.api_torrent_action_start(id)
|
state.api()?.api_torrent_action_start(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn torrent_action_configure(
|
||||||
|
state: tauri::State<'_, State>,
|
||||||
|
id: usize,
|
||||||
|
only_files: Vec<usize>,
|
||||||
|
) -> Result<EmptyJsonResponse, ApiError> {
|
||||||
|
state
|
||||||
|
.api()?
|
||||||
|
.api_torrent_action_update_only_files(id, &only_files.into_iter().collect())
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn get_version() -> &'static str {
|
fn get_version() -> &'static str {
|
||||||
env!("CARGO_PKG_VERSION")
|
env!("CARGO_PKG_VERSION")
|
||||||
|
|
@ -325,6 +336,7 @@ async fn start() {
|
||||||
torrent_action_pause,
|
torrent_action_pause,
|
||||||
torrent_action_forget,
|
torrent_action_forget,
|
||||||
torrent_action_start,
|
torrent_action_start,
|
||||||
|
torrent_action_configure,
|
||||||
torrent_create_from_base64_file,
|
torrent_create_from_base64_file,
|
||||||
get_version,
|
get_version,
|
||||||
config_default,
|
config_default,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ interface InvokeErrorResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorToUIError(
|
function errorToUIError(
|
||||||
path: string
|
path: string,
|
||||||
): (e: InvokeErrorResponse) => Promise<never> {
|
): (e: InvokeErrorResponse) => Promise<never> {
|
||||||
return (e: InvokeErrorResponse) => {
|
return (e: InvokeErrorResponse) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
@ -35,11 +35,11 @@ function errorToUIError(
|
||||||
|
|
||||||
export async function invokeAPI<Response>(
|
export async function invokeAPI<Response>(
|
||||||
name: string,
|
name: string,
|
||||||
params?: InvokeArgs
|
params?: InvokeArgs,
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
console.log("invoking", name, params);
|
console.log("invoking", name, params);
|
||||||
const result = await invoke<Response>(name, params).catch(
|
const result = await invoke<Response>(name, params).catch(
|
||||||
errorToUIError(name)
|
errorToUIError(name),
|
||||||
);
|
);
|
||||||
console.log(result);
|
console.log(result);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -96,7 +96,7 @@ export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => {
|
||||||
{
|
{
|
||||||
contents,
|
contents,
|
||||||
opts: opts ?? {},
|
opts: opts ?? {},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return await invokeAPI<AddTorrentResponse>("torrent_create_from_url", {
|
return await invokeAPI<AddTorrentResponse>("torrent_create_from_url", {
|
||||||
|
|
@ -104,6 +104,12 @@ export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => {
|
||||||
opts: opts ?? {},
|
opts: opts ?? {},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
updateOnlyFiles: function (id, files): Promise<void> {
|
||||||
|
return invokeAPI<void>("torrent_action_configure", {
|
||||||
|
id: id,
|
||||||
|
onlyFiles: files,
|
||||||
|
});
|
||||||
|
},
|
||||||
pause: function (id: number): Promise<void> {
|
pause: function (id: number): Promise<void> {
|
||||||
return invokeAPI<void>("torrent_action_pause", { id });
|
return invokeAPI<void>("torrent_action_pause", { id });
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue