mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-21 02:20:48 +08:00
bin: Use improved app creation interface
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user