Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add pick_artifact_files / pick_artifact_directory
Daniel Norman committed 7 days ago
commit 412a9ce04aa9373fe955e8ec69cebbe7885273b6
parent 6896359a3c4125272a2bc676e637009f081e1aef
2 files changed +37 -0
modified crates/radicle-tauri/src/commands/cob/release.rs
@@ -270,6 +270,41 @@ pub async fn download_artifact(
    Ok(())
}

+
// File picker ---------------------------------------------------------------
+

+
use tauri_plugin_dialog::DialogExt;
+

+
/// Open a multi-file picker. Returns the selected paths as strings, or an
+
/// empty Vec if the user cancelled. The frontend feeds each path into
+
/// `compute_artifact_cid` then `add_artifact`.
+
#[tauri::command]
+
pub async fn pick_artifact_files(app: tauri::AppHandle) -> Result<Vec<String>, Error> {
+
    let (tx, rx) = tokio::sync::oneshot::channel();
+
    app.dialog().file().pick_files(move |paths| {
+
        let _ = tx.send(paths.unwrap_or_default());
+
    });
+
    let paths = rx.await.map_err(|e| Error::Iroh(format!("dialog: {e}")))?;
+
    Ok(paths
+
        .into_iter()
+
        .filter_map(|p| p.into_path().ok())
+
        .map(|p| p.to_string_lossy().into_owned())
+
        .collect())
+
}
+

+
/// Open a single-directory picker. Used when the user wants to attach a
+
/// directory artifact (which becomes a Collection CID).
+
#[tauri::command]
+
pub async fn pick_artifact_directory(app: tauri::AppHandle) -> Result<Option<String>, Error> {
+
    let (tx, rx) = tokio::sync::oneshot::channel();
+
    app.dialog().file().pick_folder(move |path| {
+
        let _ = tx.send(path);
+
    });
+
    let path = rx.await.map_err(|e| Error::Iroh(format!("dialog: {e}")))?;
+
    Ok(path
+
        .and_then(|p| p.into_path().ok())
+
        .map(|p| p.to_string_lossy().into_owned()))
+
}
+

// Settings ------------------------------------------------------------------

#[tauri::command]
modified crates/radicle-tauri/src/lib.rs
@@ -58,6 +58,8 @@ pub fn run() {
            cob::release::unseed_artifact,
            cob::release::is_seeding,
            cob::release::download_artifact,
+
            cob::release::pick_artifact_files,
+
            cob::release::pick_artifact_directory,
            cob::release::get_auto_seed_artifacts,
            cob::release::set_auto_seed_artifacts,
            cob::save_embed_by_bytes,