Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
bin: Use improved app creation interface
Erik Kundt committed 2 years ago
commit 71452e7e305558b00c674e7cd86f06f429b5cc15
parent f929fd8fe57f078b36857fe3c8ce6025896ae3d6
3 files changed +20 -70
modified bin/commands/inbox/select.rs
@@ -14,15 +14,13 @@ use radicle::storage::git::Repository;
use radicle::Profile;
use radicle_tui as tui;

-
use tui::cob::inbox::{self};
+
use tui::cob::inbox;
use tui::store;
use tui::store::StateValue;
-
use tui::task;
-
use tui::task::Interrupted;
use tui::ui::items::{Filter, NotificationItem, NotificationItemFilter};
use tui::ui::widget::window::{Window, WindowProps};
use tui::ui::widget::{Properties, Widget};
-
use tui::ui::Frontend;
+
use tui::Channel;
use tui::Exit;

use tui::PageStack;
@@ -277,19 +275,16 @@ impl App {
    }

    pub async fn run(&self) -> Result<Option<Selection>> {
-
        let (terminator, mut interrupt_rx) = task::create_termination();
-
        let (store, state_rx) = store::Store::<Action, State, Selection>::new();
-
        let (frontend, action_tx, action_rx) = Frontend::new();
+
        let channel = Channel::default();
        let state = State::try_from(&self.context)?;
-

-
        let window: Window<State, Action, Page> = Window::new(&state, action_tx.clone())
+
        let window: Window<State, Action, Page> = Window::new(&state, channel.tx.clone())
            .page(
                Page::Browse,
-
                BrowserPage::new(&state, action_tx.clone()).to_boxed(),
+
                BrowserPage::new(&state, channel.tx.clone()).to_boxed(),
            )
            .page(
                Page::Help,
-
                HelpPage::new(&state, action_tx.clone()).to_boxed(),
+
                HelpPage::new(&state, channel.tx.clone()).to_boxed(),
            )
            .on_update(|state| {
                WindowProps::default()
@@ -297,18 +292,6 @@ impl App {
                    .to_boxed()
            });

-
        tokio::try_join!(
-
            store.main_loop(state, terminator, action_rx, interrupt_rx.resubscribe()),
-
            frontend.main_loop(Some(window), state_rx, interrupt_rx.resubscribe()),
-
        )?;
-

-
        if let Ok(reason) = interrupt_rx.recv().await {
-
            match reason {
-
                Interrupted::User { payload } => Ok(payload),
-
                Interrupted::OsSignal => anyhow::bail!("exited because of an os sig int"),
-
            }
-
        } else {
-
            anyhow::bail!("exited because of an unexpected error");
-
        }
+
        tui::run(channel, state, window).await
    }
}
modified bin/commands/issue/select.rs
@@ -13,12 +13,11 @@ use radicle_tui as tui;

use tui::cob::issue;
use tui::store::StateValue;
-
use tui::task;
-
use tui::task::Interrupted;
use tui::ui::items::{Filter, IssueItem, IssueItemFilter};
use tui::ui::widget::window::{Window, WindowProps};
use tui::ui::widget::{Properties, Widget};
-
use tui::ui::Frontend;
+
use tui::Channel;
+

use tui::Exit;
use tui::{store, PageStack};

@@ -195,19 +194,16 @@ impl App {
    }

    pub async fn run(&self) -> Result<Option<Selection>> {
-
        let (terminator, mut interrupt_rx) = task::create_termination();
-
        let (store, state_rx) = store::Store::<Action, State, Selection>::new();
-
        let (frontend, action_tx, action_rx) = Frontend::new();
+
        let channel = Channel::default();
        let state = State::try_from(&self.context)?;
-

-
        let window: Window<State, Action, Page> = Window::new(&state, action_tx.clone())
+
        let window: Window<State, Action, Page> = Window::new(&state, channel.tx.clone())
            .page(
                Page::Browse,
-
                BrowserPage::new(&state, action_tx.clone()).to_boxed(),
+
                BrowserPage::new(&state, channel.tx.clone()).to_boxed(),
            )
            .page(
                Page::Help,
-
                HelpPage::new(&state, action_tx.clone()).to_boxed(),
+
                HelpPage::new(&state, channel.tx.clone()).to_boxed(),
            )
            .on_update(|state| {
                WindowProps::default()
@@ -215,18 +211,6 @@ impl App {
                    .to_boxed()
            });

-
        tokio::try_join!(
-
            store.main_loop(state, terminator, action_rx, interrupt_rx.resubscribe()),
-
            frontend.main_loop(Some(window), state_rx, interrupt_rx.resubscribe()),
-
        )?;
-

-
        if let Ok(reason) = interrupt_rx.recv().await {
-
            match reason {
-
                Interrupted::User { payload } => Ok(payload),
-
                Interrupted::OsSignal => anyhow::bail!("exited because of an os sig int"),
-
            }
-
        } else {
-
            anyhow::bail!("exited because of an unexpected error");
-
        }
+
        tui::run(channel, state, window).await
    }
}
modified bin/commands/patch/select.rs
@@ -13,12 +13,10 @@ use radicle_tui as tui;

use tui::cob::patch;
use tui::store;
-
use tui::task;
-
use tui::task::Interrupted;
use tui::ui::items::{Filter, PatchItem, PatchItemFilter};
use tui::ui::widget::window::{Window, WindowProps};
use tui::ui::widget::{Properties, Widget};
-
use tui::ui::Frontend;
+
use tui::Channel;
use tui::Exit;

use tui::PageStack;
@@ -197,19 +195,16 @@ impl App {
    }

    pub async fn run(&self) -> Result<Option<Selection>> {
-
        let (terminator, mut interrupt_rx) = task::create_termination();
-
        let (store, state_rx) = store::Store::<Action, State, Selection>::new();
-
        let (frontend, action_tx, action_rx) = Frontend::<Action>::new();
+
        let channel = Channel::default();
        let state = State::try_from(&self.context)?;
-

-
        let window: Window<State, Action, Page> = Window::new(&state, action_tx.clone())
+
        let window: Window<State, Action, Page> = Window::new(&state, channel.tx.clone())
            .page(
                Page::Browse,
-
                BrowserPage::new(&state, action_tx.clone()).to_boxed(),
+
                BrowserPage::new(&state, channel.tx.clone()).to_boxed(),
            )
            .page(
                Page::Help,
-
                HelpPage::new(&state, action_tx.clone()).to_boxed(),
+
                HelpPage::new(&state, channel.tx.clone()).to_boxed(),
            )
            .on_update(|state| {
                WindowProps::default()
@@ -217,18 +212,6 @@ impl App {
                    .to_boxed()
            });

-
        tokio::try_join!(
-
            store.main_loop(state, terminator, action_rx, interrupt_rx.resubscribe()),
-
            frontend.main_loop(Some(window), state_rx, interrupt_rx.resubscribe()),
-
        )?;
-

-
        if let Ok(reason) = interrupt_rx.recv().await {
-
            match reason {
-
                Interrupted::User { payload } => Ok(payload),
-
                Interrupted::OsSignal => anyhow::bail!("exited because of an os sig int"),
-
            }
-
        } else {
-
            anyhow::bail!("exited because of an unexpected error");
-
        }
+
        tui::run(channel, state, window).await
    }
}