diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index fc135bb..2b03d63 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -293,6 +293,17 @@ async fn torrent_action_start( state.api()?.api_torrent_action_start(id) } +#[tauri::command] +async fn torrent_action_configure( + state: tauri::State<'_, State>, + id: usize, + only_files: Vec, +) -> Result { + state + .api()? + .api_torrent_action_update_only_files(id, &only_files.into_iter().collect()) +} + #[tauri::command] fn get_version() -> &'static str { env!("CARGO_PKG_VERSION") @@ -325,6 +336,7 @@ async fn start() { torrent_action_pause, torrent_action_forget, torrent_action_start, + torrent_action_configure, torrent_create_from_base64_file, get_version, config_default, diff --git a/desktop/src/api.tsx b/desktop/src/api.tsx index f2f9980..6938b93 100644 --- a/desktop/src/api.tsx +++ b/desktop/src/api.tsx @@ -18,7 +18,7 @@ interface InvokeErrorResponse { } function errorToUIError( - path: string + path: string, ): (e: InvokeErrorResponse) => Promise { return (e: InvokeErrorResponse) => { console.log(e); @@ -35,11 +35,11 @@ function errorToUIError( export async function invokeAPI( name: string, - params?: InvokeArgs + params?: InvokeArgs, ): Promise { console.log("invoking", name, params); const result = await invoke(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("torrent_create_from_url", { @@ -104,6 +104,12 @@ export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => { opts: opts ?? {}, }); }, + updateOnlyFiles: function (id, files): Promise { + return invokeAPI("torrent_action_configure", { + id: id, + onlyFiles: files, + }); + }, pause: function (id: number): Promise { return invokeAPI("torrent_action_pause", { id }); },