Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Load profile in setup step
Sebastian Martinez committed 1 year ago
commit 029362787e232c2a75332df7df453f93b39f8ea7
parent 9dfc01a3c0775b97cf7c292c22966eb11cdb7512
1 file changed +27 -0
modified src-tauri/src/lib.rs
@@ -1,7 +1,34 @@
+
mod auth;
+
mod error;
+

+
use auth::authenticate;
+
use tauri::Manager;
+

+
struct AppState {
+
    profile: radicle::Profile,
+
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
+
        .setup(|app| {
+
            let profile: radicle::Profile = match radicle::Profile::load() {
+
                Ok(profile) => Ok::<radicle::Profile, error::Error>(profile),
+
                Err(radicle::profile::Error::NotFound(path)) => Err(error::Error::WithHint {
+
                    err: anyhow::anyhow!("Radicle profile not found in '{}'.", path.display()),
+
                    hint: "To setup your radicle profile, run `rad auth`.",
+
                }
+
                .into()),
+
                Err(e) => Err(error::Error::WithHint {
+
                    err: e.into(),
+
                    hint: "Could not load radicle profile",
+
                }),
+
            }?;
+

+
            app.manage(AppState { profile });
+

+
            Ok(())
+
        })
        .plugin(tauri_plugin_shell::init())
        .plugin(tauri_plugin_window_state::Builder::default().build())
        .run(tauri::generate_context!())