From 53116804e7059dab3f13b914c74fdfeabe26f7ea Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 24 Apr 2024 14:16:22 +0200 Subject: [PATCH] inbox: Remove unnecessary generic backend parameter --- bin/commands/inbox/select.rs | 3 +- bin/commands/inbox/select/ui.rs | 53 +++++++++++---------------------- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/bin/commands/inbox/select.rs b/bin/commands/inbox/select.rs index 9d6906b8..0f0babf4 100644 --- a/bin/commands/inbox/select.rs +++ b/bin/commands/inbox/select.rs @@ -18,7 +18,6 @@ use tui::cob::inbox::{self}; use tui::store; use tui::store::StateValue; use tui::task::{self, Interrupted}; -use tui::terminal::Backend; use tui::ui::items::{Filter, NotificationItem, NotificationItemFilter}; use tui::ui::widget::{Properties, View, Window, WindowProps}; use tui::ui::Frontend; @@ -281,7 +280,7 @@ impl App { let (frontend, action_tx, action_rx) = Frontend::new(); let state = State::try_from(&self.context)?; - let window: Window = Window::new(&state, action_tx.clone()) + let window: Window = Window::new(&state, action_tx.clone()) .page( Page::Browse, BrowsePage::new(&state, action_tx.clone()).to_boxed(), diff --git a/bin/commands/inbox/select/ui.rs b/bin/commands/inbox/select/ui.rs index e7dc91d3..cede4bde 100644 --- a/bin/commands/inbox/select/ui.rs +++ b/bin/commands/inbox/select/ui.rs @@ -7,7 +7,6 @@ use tokio::sync::mpsc::UnboundedSender; use termion::event::Key; -use ratatui::backend::Backend; use ratatui::layout::{Constraint, Layout, Rect}; use ratatui::style::Stylize; use ratatui::text::{Line, Span, Text}; @@ -31,7 +30,7 @@ use crate::tui_inbox::common::{InboxOperation, Mode, RepositoryMode, SelectionMo use super::{Action, State}; -type BoxedWidget = widget::BoxedWidget; +type BoxedWidget = widget::BoxedWidget; #[derive(Clone)] struct BrowsePageProps<'a> { @@ -106,23 +105,20 @@ impl<'a> From<&State> for BrowsePageProps<'a> { impl<'a> Properties for BrowsePageProps<'a> {} -pub struct BrowsePage<'a, B> { +pub struct BrowsePage<'a> { /// Internal base base: BaseView, /// Internal props props: BrowsePageProps<'a>, /// Notifications widget - notifications: BoxedWidget, + notifications: BoxedWidget, /// Search widget - search: BoxedWidget, + search: BoxedWidget, /// Shortcut widget - shortcuts: BoxedWidget, + shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for BrowsePage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> View for BrowsePage<'a> { type Action = Action; type State = State; @@ -267,7 +263,7 @@ where } } -impl<'a, B: Backend> BrowsePage<'a, B> { +impl<'a> BrowsePage<'a> { fn build_footer(props: &BrowsePageProps<'a>, selected: Option) -> Vec> { let search = Line::from(vec![ span::default(" Search ").cyan().dim().reversed(), @@ -330,10 +326,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> { } } -impl<'a: 'static, B> Widget for BrowsePage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> Widget for BrowsePage<'a> { fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option>) { let props = props .and_then(BrowsePageProps::from_boxed_any) @@ -390,16 +383,16 @@ pub struct SearchProps {} impl Properties for SearchProps {} -pub struct Search { +pub struct Search { /// Internal base base: BaseView, /// Internal props _props: SearchProps, /// Search input field - input: BoxedWidget, + input: BoxedWidget, } -impl View for Search { +impl View for Search { type Action = Action; type State = State; @@ -459,10 +452,7 @@ impl View for Search { } } -impl Widget for Search -where - B: Backend, -{ +impl Widget for Search { fn render(&self, frame: &mut ratatui::Frame, area: Rect, _props: Option>) { let layout = Layout::horizontal(Constraint::from_mins([0])) .horizontal_margin(1) @@ -493,24 +483,18 @@ impl<'a> From<&State> for HelpPageProps<'a> { impl<'a> Properties for HelpPageProps<'a> {} -pub struct HelpPage<'a, B> -where - B: Backend, -{ +pub struct HelpPage<'a> { /// Internal base base: BaseView, /// Internal props props: HelpPageProps<'a>, /// Content widget - content: BoxedWidget, + content: BoxedWidget, /// Shortcut widget - shortcuts: BoxedWidget, + shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for HelpPage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> View for HelpPage<'a> { type Action = Action; type State = State; @@ -613,10 +597,7 @@ where } } -impl<'a: 'static, B> Widget for HelpPage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> Widget for HelpPage<'a> { fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option>) { let props = props .and_then(HelpPageProps::from_boxed_any)