Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
bin: Use associated types in views
Erik Kundt committed 2 years ago
commit 0c628a2a4437af6af15f0d6a3eb159dc02c9755b
parent 166add7780136bcb0a1dc07f5bdbd4a2eb361075
6 files changed +56 -23
modified bin/commands/inbox/select.rs
@@ -210,7 +210,9 @@ pub enum Action {
    ScrollHelp { progress: usize },
}

-
impl store::State<Action, Selection> for State {
+
impl store::State<Selection> for State {
+
    type Action = Action;
+

    fn tick(&self) {}

    fn handle_action(&mut self, action: Action) -> Option<Exit<Selection>> {
modified bin/commands/inbox/select/ui.rs
@@ -119,10 +119,13 @@ pub struct BrowsePage<'a, B> {
    shortcuts: BoxedWidget<B>,
}

-
impl<'a: 'static, B> View<State, Action> for BrowsePage<'a, B>
+
impl<'a: 'static, B> View for BrowsePage<'a, B>
where
    B: Backend + 'a,
{
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self {
        let props = BrowsePageProps::from(state);
        let name = match state.mode.repository() {
@@ -327,7 +330,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> {
    }
}

-
impl<'a: 'static, B> Widget<B, State, Action> for BrowsePage<'a, B>
+
impl<'a: 'static, B> Widget<B> for BrowsePage<'a, B>
where
    B: Backend + 'a,
{
@@ -396,7 +399,10 @@ pub struct Search<B: Backend> {
    input: BoxedWidget<B>,
}

-
impl<B: Backend> View<State, Action> for Search<B> {
+
impl<B: Backend> View for Search<B> {
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self
    where
        Self: Sized,
@@ -453,7 +459,7 @@ impl<B: Backend> View<State, Action> for Search<B> {
    }
}

-
impl<B> Widget<B, State, Action> for Search<B>
+
impl<B> Widget<B> for Search<B>
where
    B: Backend,
{
@@ -501,10 +507,13 @@ where
    shortcuts: BoxedWidget<B>,
}

-
impl<'a: 'static, B> View<State, Action> for HelpPage<'a, B>
+
impl<'a: 'static, B> View for HelpPage<'a, B>
where
    B: Backend + 'a,
{
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self
    where
        Self: Sized,
@@ -604,7 +613,7 @@ where
    }
}

-
impl<'a: 'static, B> Widget<B, State, Action> for HelpPage<'a, B>
+
impl<'a: 'static, B> Widget<B> for HelpPage<'a, B>
where
    B: Backend + 'a,
{
modified bin/commands/issue/select.rs
@@ -129,8 +129,8 @@ pub enum Action {
    ScrollHelp { progress: usize },
}

-
impl store::State<Action, Selection> for State {
-
    fn tick(&self) {}
+
impl store::State<Selection> for State {
+
    type Action = Action;

    fn handle_action(&mut self, action: Action) -> Option<Exit<Selection>> {
        match action {
@@ -185,6 +185,8 @@ impl store::State<Action, Selection> for State {
            }
        }
    }
+

+
    fn tick(&self) {}
}

impl App {
modified bin/commands/issue/select/ui.rs
@@ -133,10 +133,13 @@ pub struct BrowsePage<'a, B> {
    shortcuts: BoxedWidget<B>,
}

-
impl<'a: 'static, B> View<State, Action> for BrowsePage<'a, B>
+
impl<'a: 'static, B> View for BrowsePage<'a, B>
where
    B: Backend + 'a,
{
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self {
        let props = BrowsePageProps::from(state);

@@ -346,7 +349,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> {
    }
}

-
impl<'a: 'static, B> Widget<B, State, Action> for BrowsePage<'a, B>
+
impl<'a: 'static, B> Widget<B> for BrowsePage<'a, B>
where
    B: Backend + 'a,
{
@@ -415,7 +418,10 @@ pub struct Search<B: Backend> {
    input: BoxedWidget<B>,
}

-
impl<B: Backend> View<State, Action> for Search<B> {
+
impl<B: Backend> View for Search<B> {
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self
    where
        Self: Sized,
@@ -472,7 +478,7 @@ impl<B: Backend> View<State, Action> for Search<B> {
    }
}

-
impl<B> Widget<B, State, Action> for Search<B>
+
impl<B> Widget<B> for Search<B>
where
    B: Backend,
{
@@ -520,10 +526,13 @@ where
    shortcuts: BoxedWidget<B>,
}

-
impl<'a: 'static, B> View<State, Action> for HelpPage<'a, B>
+
impl<'a: 'static, B> View for HelpPage<'a, B>
where
    B: Backend + 'a,
{
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self
    where
        Self: Sized,
@@ -623,7 +632,7 @@ where
    }
}

-
impl<'a: 'static, B> Widget<B, State, Action> for HelpPage<'a, B>
+
impl<'a: 'static, B> Widget<B> for HelpPage<'a, B>
where
    B: Backend + 'a,
{
modified bin/commands/patch/select.rs
@@ -134,8 +134,8 @@ pub enum Action {
    ScrollHelp { progress: usize },
}

-
impl store::State<Action, Selection> for State {
-
    fn tick(&self) {}
+
impl store::State<Selection> for State {
+
    type Action = Action;

    fn handle_action(&mut self, action: Action) -> Option<Exit<Selection>> {
        match action {
@@ -190,6 +190,8 @@ impl store::State<Action, Selection> for State {
            }
        }
    }
+

+
    fn tick(&self) {}
}

impl App {
modified bin/commands/patch/select/ui.rs
@@ -134,10 +134,13 @@ pub struct BrowsePage<'a, B> {
    shortcuts: BoxedWidget<B>,
}

-
impl<'a: 'static, B> View<State, Action> for BrowsePage<'a, B>
+
impl<'a: 'static, B> View for BrowsePage<'a, B>
where
    B: Backend + 'a,
{
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self {
        let props = BrowsePageProps::from(state);

@@ -374,7 +377,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> {
    }
}

-
impl<'a: 'static, B> Widget<B, State, Action> for BrowsePage<'a, B>
+
impl<'a: 'static, B> Widget<B> for BrowsePage<'a, B>
where
    B: Backend + 'a,
{
@@ -443,7 +446,10 @@ pub struct Search<B: Backend> {
    input: BoxedWidget<B>,
}

-
impl<B: Backend> View<State, Action> for Search<B> {
+
impl<B: Backend> View for Search<B> {
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self
    where
        Self: Sized,
@@ -500,7 +506,7 @@ impl<B: Backend> View<State, Action> for Search<B> {
    }
}

-
impl<B> Widget<B, State, Action> for Search<B>
+
impl<B> Widget<B> for Search<B>
where
    B: Backend,
{
@@ -548,10 +554,13 @@ where
    shortcuts: BoxedWidget<B>,
}

-
impl<'a: 'static, B> View<State, Action> for HelpPage<'a, B>
+
impl<'a: 'static, B> View for HelpPage<'a, B>
where
    B: Backend + 'a,
{
+
    type Action = Action;
+
    type State = State;
+

    fn new(state: &State, action_tx: UnboundedSender<Action>) -> Self
    where
        Self: Sized,
@@ -651,7 +660,7 @@ where
    }
}

-
impl<'a: 'static, B> Widget<B, State, Action> for HelpPage<'a, B>
+
impl<'a: 'static, B> Widget<B> for HelpPage<'a, B>
where
    B: Backend + 'a,
{