Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add signer to app context
Erik Kundt committed 2 years ago
commit c79caff79ade0ac8e4ed43812c926834b785c1d1
parent e6cc2235f2491812814f40dc765e6da05abdaefc
3 files changed +13 -5
modified src/app.rs
@@ -7,6 +7,7 @@ use anyhow::Result;
use radicle::cob::issue::IssueId;
use radicle::cob::patch::PatchId;
use radicle::identity::{Id, Project};
+
use radicle::prelude::Signer;
use radicle::profile::Profile;

use radicle_tui::ui::widget;
@@ -113,9 +114,9 @@ pub struct App {
/// Creates a new application using a tui-realm-application, mounts all
/// components and sets focus to a default one.
impl App {
-
    pub fn new(profile: Profile, id: Id, project: Project) -> Self {
+
    pub fn new(profile: Profile, id: Id, project: Project, signer: Box<dyn Signer>) -> Self {
        Self {
-
            context: Context::new(profile, id, project),
+
            context: Context::new(profile, id, project, signer),
            pages: PageStack::default(),
            theme: theme::default_dark(),
            quit: false,
modified src/main.rs
@@ -104,7 +104,7 @@ fn execute() -> anyhow::Result<()> {
    info!("Launching window...");

    let mut window = Window::default();
-
    window.run(&mut app::App::new(profile, id, project), 1000 / FPS)?;
+
    window.run(&mut app::App::new(profile, id, project, signer), 1000 / FPS)?;

    Ok(())
}
modified src/ui/context.rs
@@ -1,6 +1,6 @@
use radicle::cob::issue::{Issue, IssueId};
use radicle::cob::patch::{Patch, PatchId};
-
use radicle::prelude::{Id, Project};
+
use radicle::prelude::{Id, Project, Signer};
use radicle::Profile;

use radicle::storage::git::Repository;
@@ -12,10 +12,11 @@ pub struct Context {
    repository: Repository,
    issues: Vec<(IssueId, Issue)>,
    patches: Vec<(PatchId, Patch)>,
+
    signer: Box<dyn Signer>,
}

impl Context {
-
    pub fn new(profile: Profile, id: Id, project: Project) -> Self {
+
    pub fn new(profile: Profile, id: Id, project: Project, signer: Box<dyn Signer>) -> Self {
        let repository = profile.storage.repository(id).unwrap();
        let issues = crate::cob::issue::all(&repository).unwrap_or_default();
        let patches = crate::cob::patch::all(&repository).unwrap_or_default();
@@ -27,6 +28,7 @@ impl Context {
            repository,
            issues,
            patches,
+
            signer,
        }
    }

@@ -53,4 +55,9 @@ impl Context {
    pub fn patches(&self) -> &Vec<(PatchId, Patch)> {
        &self.patches
    }
+

+
    #[allow(clippy::borrowed_box)]
+
    pub fn signer(&self) -> &Box<dyn Signer> {
+
        &self.signer
+
    }
}