diff --git a/bin/commands/patch/review.rs b/bin/commands/patch/review.rs index 460b7eb7..cf5877d8 100644 --- a/bin/commands/patch/review.rs +++ b/bin/commands/patch/review.rs @@ -8,17 +8,15 @@ use std::sync::Mutex; use anyhow::Result; -use radicle::patch::Review; use ratatui::layout::Position; +use ratatui::layout::{Constraint, Layout}; use ratatui::style::Stylize; use ratatui::text::Text; +use ratatui::{Frame, Viewport}; use termion::event::Key; -use ratatui::layout::{Constraint, Layout}; -use ratatui::{Frame, Viewport}; - use radicle::identity::RepoId; -use radicle::storage::git::Repository; +use radicle::patch::Review; use radicle::storage::ReadStorage; use radicle::Profile; @@ -139,8 +137,6 @@ pub struct ReviewItemState { #[derive(Clone)] pub struct App<'a> { - repository: Arc>, - review: Arc>, queue: Arc>, TableState)>>, items: HashMap, page: AppPage, @@ -165,7 +161,7 @@ impl<'a> App<'a> { pub fn new( profile: Profile, rid: RepoId, - review: Review, + _review: Review, queue: ReviewQueue, ) -> Result { let repository = profile.storage.repository(rid)?; @@ -186,13 +182,11 @@ impl<'a> App<'a> { } Ok(Self { - repository: Arc::new(Mutex::new(repository)), page: AppPage::Main, windows: GroupState::new(2, Some(0)), help: HelpState { text: TextViewState::new(help_text(), Position::default()), }, - review: Arc::new(Mutex::new(review)), queue: Arc::new(Mutex::new((queue, TableState::new(Some(0))))), items, }) @@ -220,7 +214,6 @@ impl<'a> App<'a> { } fn show_review_item(&self, ui: &mut Ui, frame: &mut Frame) { - let repo = self.repository.lock().unwrap(); let queue = self.queue.lock().unwrap(); let selected = queue.1.selected(); @@ -229,7 +222,7 @@ impl<'a> App<'a> { if let Some(item) = item { let header = item.header(); let hunk = item - .hunk_text(&repo) + .hunk_text() .unwrap_or(Text::raw("Nothing to show.").dark_gray()); let mut cursor = selected @@ -243,7 +236,7 @@ impl<'a> App<'a> { |ui| { ui.columns(frame, header, Some(Borders::Top)); - if let Some(hunk) = item.hunk_text(&repo) { + if let Some(hunk) = item.hunk_text() { let diff = ui.text_view(frame, hunk, &mut cursor, Some(Borders::BottomSides)); if diff.changed { diff --git a/bin/ui/items.rs b/bin/ui/items.rs index 7362e43e..b4193474 100644 --- a/bin/ui/items.rs +++ b/bin/ui/items.rs @@ -1443,7 +1443,7 @@ impl<'a> HunkItem<'a> { } } - pub fn hunk_text(&'a self, repo: &Repository) -> Option> { + pub fn hunk_text(&'a self) -> Option> { match &self.inner { ( _, @@ -1455,7 +1455,7 @@ impl<'a> HunkItem<'a> { }, ) => hunk .as_ref() - .map(|hunk| Text::from(hunk.to_text(&self.highlighted, repo.raw()))), + .map(|hunk| Text::from(hunk.to_text(&self.highlighted))), ( _, crate::cob::HunkItem::FileModified { @@ -1467,7 +1467,7 @@ impl<'a> HunkItem<'a> { }, ) => hunk .as_ref() - .map(|hunk| Text::from(hunk.to_text(&self.highlighted, repo.raw()))), + .map(|hunk| Text::from(hunk.to_text(&self.highlighted))), ( _, crate::cob::HunkItem::FileDeleted { @@ -1478,7 +1478,7 @@ impl<'a> HunkItem<'a> { }, ) => hunk .as_ref() - .map(|hunk| Text::from(hunk.to_text(&self.highlighted, repo.raw()))), + .map(|hunk| Text::from(hunk.to_text(&self.highlighted))), _ => None, } } @@ -1582,14 +1582,14 @@ pub trait ToText<'a> { type Context; /// Render to pretty diff output. - fn to_text(&'a self, context: &Self::Context, repo: &R) -> Self::Output; + fn to_text(&'a self, context: &Self::Context) -> Self::Output; } impl<'a> ToText<'a> for HunkHeader { type Output = Line<'a>; type Context = (); - fn to_text(&self, _context: &Self::Context, _repo: &R) -> Self::Output { + fn to_text(&self, _context: &Self::Context) -> Self::Output { Line::from( [ span::default(&format!( @@ -1609,7 +1609,7 @@ impl<'a> ToText<'a> for Modification { type Output = Line<'a>; type Context = Blobs>>; - fn to_text(&'a self, blobs: &Blobs>>, _repo: &R) -> Self::Output { + fn to_text(&'a self, blobs: &Blobs>>) -> Self::Output { let line = match self { Modification::Deletion(diff::Deletion { line, line_no }) => { if let Some(lines) = &blobs.old.as_ref() { @@ -1645,7 +1645,7 @@ impl<'a> ToText<'a> for Hunk { type Output = Vec>; type Context = Blobs>>; - fn to_text(&'a self, blobs: &Self::Context, repo: &R) -> Self::Output { + fn to_text(&'a self, blobs: &Self::Context) -> Self::Output { let mut lines: Vec> = vec![]; let default_dark = Color::Rgb(20, 20, 20); @@ -1689,7 +1689,7 @@ impl<'a> ToText<'a> for Hunk { span::positive(" + ").bg(positive_dark).dim(), ] .to_vec(), - line.to_text(blobs, repo) + line.to_text(blobs) .spans .into_iter() .map(|span| span.bg(positive_dark)) @@ -1712,7 +1712,7 @@ impl<'a> ToText<'a> for Hunk { span::negative(" - ").bg(negative_dark).dim(), ] .to_vec(), - line.to_text(blobs, repo) + line.to_text(blobs) .spans .into_iter() .map(|span| span.bg(negative_dark)) @@ -1741,7 +1741,7 @@ impl<'a> ToText<'a> for Hunk { span::default(&format!("{:<3}", "")), ] .to_vec(), - line.to_text(blobs, repo).spans, + line.to_text(blobs).spans, ] .concat(), ));