inbox: Remove unnecessary generic backend parameter

This commit is contained in:
Erik Kundt
2024-04-24 14:16:22 +02:00
parent 92de3c80d4
commit 53116804e7
2 changed files with 18 additions and 38 deletions
+1 -2
View File
@@ -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<Backend, State, Action, Page> = Window::new(&state, action_tx.clone())
let window: Window<State, Action, Page> = Window::new(&state, action_tx.clone())
.page(
Page::Browse,
BrowsePage::new(&state, action_tx.clone()).to_boxed(),
+17 -36
View File
@@ -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<B> = widget::BoxedWidget<B, State, Action>;
type BoxedWidget = widget::BoxedWidget<State, Action>;
#[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<State, Action>,
/// Internal props
props: BrowsePageProps<'a>,
/// Notifications widget
notifications: BoxedWidget<B>,
notifications: BoxedWidget,
/// Search widget
search: BoxedWidget<B>,
search: BoxedWidget,
/// Shortcut widget
shortcuts: BoxedWidget<B>,
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<usize>) -> Vec<Column<'a>> {
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<B> 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<Box<dyn Any>>) {
let props = props
.and_then(BrowsePageProps::from_boxed_any)
@@ -390,16 +383,16 @@ pub struct SearchProps {}
impl Properties for SearchProps {}
pub struct Search<B: Backend> {
pub struct Search {
/// Internal base
base: BaseView<State, Action>,
/// Internal props
_props: SearchProps,
/// Search input field
input: BoxedWidget<B>,
input: BoxedWidget,
}
impl<B: Backend> View for Search<B> {
impl View for Search {
type Action = Action;
type State = State;
@@ -459,10 +452,7 @@ impl<B: Backend> View for Search<B> {
}
}
impl<B> Widget<B> for Search<B>
where
B: Backend,
{
impl Widget for Search {
fn render(&self, frame: &mut ratatui::Frame, area: Rect, _props: Option<Box<dyn Any>>) {
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<State, Action>,
/// Internal props
props: HelpPageProps<'a>,
/// Content widget
content: BoxedWidget<B>,
content: BoxedWidget,
/// Shortcut widget
shortcuts: BoxedWidget<B>,
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<B> 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<Box<dyn Any>>) {
let props = props
.and_then(HelpPageProps::from_boxed_any)