diff --git a/radicle-tui/src/app/page.rs b/radicle-tui/src/app/page.rs index 89be284d..f5adbace 100644 --- a/radicle-tui/src/app/page.rs +++ b/radicle-tui/src/app/page.rs @@ -75,10 +75,9 @@ impl ViewPage for HomeView { ) -> Result<()> { let navigation = widget::home::navigation(theme).to_boxed(); - let dashboard = widget::home::dashboard(theme, context.id(), context.project()).to_boxed(); - let issue_browser = widget::home::issues(theme, context.id(), context.profile()).to_boxed(); - let patch_browser = - widget::home::patches(theme, context.id(), context.profile()).to_boxed(); + let dashboard = widget::home::dashboard(context, theme).to_boxed(); + let issue_browser = widget::home::issues(context, theme).to_boxed(); + let patch_browser = widget::home::patches(context, theme).to_boxed(); app.remount(Cid::Home(HomeCid::Navigation), navigation, vec![])?; diff --git a/radicle-tui/src/ui/widget/home.rs b/radicle-tui/src/ui/widget/home.rs index b8a2c5c2..eae58466 100644 --- a/radicle-tui/src/ui/widget/home.rs +++ b/radicle-tui/src/ui/widget/home.rs @@ -1,7 +1,5 @@ use radicle::cob::issue::Issues; -use radicle::prelude::{Id, Project}; use radicle::storage::ReadStorage; -use radicle::Profile; use radicle::cob::patch::Patches; @@ -17,6 +15,7 @@ use super::common::list::{ColumnWidth, Table}; use super::{Widget, WidgetComponent}; use crate::ui::cob::{IssueItem, PatchItem}; +use crate::ui::context::Context; use crate::ui::layout; use crate::ui::theme::Theme; @@ -59,8 +58,8 @@ pub struct IssueBrowser { } impl IssueBrowser { - pub fn new(theme: &Theme, profile: &Profile, id: &Id, shortcuts: Widget) -> Self { - let repo = profile.storage.repository(*id).unwrap(); + pub fn new(context: &Context, theme: &Theme, shortcuts: Widget) -> Self { + let repo = context.profile().storage.repository(*context.id()).unwrap(); let issues = Issues::open(&repo) .and_then(|issues| issues.all().map(|iter| iter.flatten().collect::>())); @@ -90,7 +89,7 @@ impl IssueBrowser { issues.sort_by(|(_, a, _), (_, b, _)| a.state().cmp(b.state())); for (id, patch, _) in issues { - if let Ok(item) = IssueItem::try_from((profile, &repo, id, patch)) { + if let Ok(item) = IssueItem::try_from((context.profile(), &repo, id, patch)) { items.push(item); } } @@ -135,8 +134,8 @@ pub struct PatchBrowser { } impl PatchBrowser { - pub fn new(profile: &Profile, id: &Id, shortcuts: Widget, theme: Theme) -> Self { - let repo = profile.storage.repository(*id).unwrap(); + pub fn new(context: &Context, theme: &Theme, shortcuts: Widget) -> Self { + let repo = context.profile().storage.repository(*context.id()).unwrap(); let patches = Patches::open(&repo) .and_then(|patches| patches.all().map(|iter| iter.flatten().collect::>())); @@ -168,7 +167,7 @@ impl PatchBrowser { patches.sort_by(|(_, a, _), (_, b, _)| a.state().cmp(b.state())); for (id, patch, _) in patches { - if let Ok(item) = PatchItem::try_from((profile, &repo, id, patch)) { + if let Ok(item) = PatchItem::try_from((context.profile(), &repo, id, patch)) { items.push(item); } } @@ -218,16 +217,16 @@ pub fn navigation(theme: &Theme) -> Widget { ) } -pub fn dashboard(theme: &Theme, id: &Id, project: &Project) -> Widget { +pub fn dashboard(context: &Context, theme: &Theme) -> Widget { let about = common::labeled_container( theme, "about", common::property_list( theme, vec![ - common::property(theme, "id", &id.to_string()), - common::property(theme, "name", project.name()), - common::property(theme, "description", project.description()), + common::property(theme, "id", &context.id().to_string()), + common::property(theme, "name", context.project().name()), + common::property(theme, "description", context.project().description()), ], ) .to_boxed(), @@ -244,7 +243,7 @@ pub fn dashboard(theme: &Theme, id: &Id, project: &Project) -> Widget Widget::new(dashboard) } -pub fn patches(theme: &Theme, id: &Id, profile: &Profile) -> Widget { +pub fn patches(context: &Context, theme: &Theme) -> Widget { let shortcuts = common::shortcuts( theme, vec![ @@ -255,10 +254,10 @@ pub fn patches(theme: &Theme, id: &Id, profile: &Profile) -> Widget Widget { +pub fn issues(context: &Context, theme: &Theme) -> Widget { let shortcuts = common::shortcuts( theme, vec![ @@ -269,5 +268,5 @@ pub fn issues(theme: &Theme, id: &Id, profile: &Profile) -> Widget ], ); - Widget::new(IssueBrowser::new(theme, profile, id, shortcuts)) + Widget::new(IssueBrowser::new(context, theme, shortcuts)) }