Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Split iroh state into IrohState
Daniel Norman committed 7 days ago
commit 9dad32757622cc532e1ee5f21be289687272fee2
parent 20cf6ba44a9b2daac19fe7218162e803175287ab
3 files changed +15 -7
modified crates/radicle-tauri/src/commands/startup.rs
@@ -7,7 +7,7 @@ use radicle_types::config::{Config, Version};
use radicle_types::error::Error;
use radicle_types::seeder;
use radicle_types::traits::Profile;
-
use radicle_types::{domain, AppState};
+
use radicle_types::{domain, AppState, IrohState};

#[tauri::command]
pub(crate) fn version(app: AppHandle) -> Result<Version, Error> {
@@ -101,12 +101,12 @@ pub(crate) async fn startup(app: AppHandle) -> Result<Config, Error> {
        }
    });

-
    let state = AppState {
-
        profile,
+
    let state = AppState { profile };
+
    app.manage(state.clone());
+
    app.manage(IrohState {
        blobs: seeder.blobs,
        iroh_router: seeder.router,
-
    };
-
    app.manage(state.clone());
+
    });

    Ok(state.config())
}
modified crates/radicle-tauri/src/lib.rs
@@ -1,6 +1,6 @@
mod commands;

-
use radicle_types::AppState;
+
use radicle_types::{AppState, IrohState};
use tauri::Manager;

use commands::{auth, cob, diff, inbox, profile, repo, startup, thread};
@@ -82,7 +82,7 @@ pub fn run() {
            // Shut down the iroh router cleanly so peers see us go away
            // instead of timing out.
            if let tauri::RunEvent::Exit = event {
-
                if let Some(state) = app.try_state::<AppState>() {
+
                if let Some(state) = app.try_state::<IrohState>() {
                    log::info!("Shutting down iroh router");
                    let router = state.iroh_router.clone();
                    tauri::async_runtime::block_on(async move {
modified crates/radicle-types/src/lib.rs
@@ -23,6 +23,14 @@ pub mod traits;
#[derive(Clone)]
pub struct AppState {
    pub profile: radicle::Profile,
+
}
+

+
/// Iroh networking state. Held separately from `AppState` so command handlers
+
/// and tests that don't touch iroh don't need to construct it. Both are
+
/// `app.manage()`-d at startup, so there is no staged-unlock — the seeder is
+
/// always available once the frontend can call commands.
+
#[derive(Clone)]
+
pub struct IrohState {
    pub blobs: iroh_blobs::store::fs::FsStore,
    pub iroh_router: iroh::protocol::Router,
}