| |
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]
|