Add signer to app context

This commit is contained in:
Erik Kundt
2023-08-11 11:44:52 +02:00
parent e6cc2235f2
commit c79caff79a
3 changed files with 13 additions and 5 deletions
+3 -2
View File
@@ -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,
+1 -1
View File
@@ -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(())
}
+9 -2
View File
@@ -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
}
}