Add App::fetch function; Fix macros

This commit is contained in:
Andreas Tsouchlos 2025-12-31 03:01:19 +02:00
parent 2e51ae8064
commit 2e942a9b31
2 changed files with 23 additions and 11 deletions

View File

@ -41,6 +41,7 @@ pub enum GlobalAction {
FetchPub,
NextTab,
Quit,
Fetch,
}
#[derive(Clone, Debug)]
@ -154,16 +155,13 @@ impl App {
self.state.status_message = StatusMessage::Info("".to_string());
}
fn add_included_publ(
&mut self,
publ: Publication,
) -> Result<(), SendError<Action>> {
// TODO: Is deduplication necessary here?
fn add_included_publ(&mut self, publ: Publication) {
self.state
.history
.current_iteration
.included_publications
.push(publ.clone());
Ok(())
}
fn fetch_publication(
@ -222,6 +220,14 @@ impl App {
self.action_tx.send(SeedingAction::ClearInput.into())
}
// TODO: Implement
fn fetch(
&self,
tx: &mpsc::UnboundedSender<Action>,
) -> Result<(), SendError<Action>> {
status_info!(tx, "Fetch action triggered from SnowballingComponent")
}
fn handle_global_action(
&mut self,
action: GlobalAction,
@ -233,7 +239,10 @@ impl App {
GlobalAction::ClearStatMsg => Ok(self.clear_stat_msg()),
GlobalAction::ShowStatMsg(msg) => Ok(self.show_stat_msg(msg, tx)),
GlobalAction::FetchPub => self.fetch_publication(tx),
GlobalAction::AddIncludedPub(publ) => self.add_included_publ(publ),
GlobalAction::AddIncludedPub(publ) => {
Ok(self.add_included_publ(publ))
}
GlobalAction::Fetch => self.fetch(tx),
}
}
@ -293,6 +302,9 @@ impl App {
(Tab::Snowballing, KeyCode::Char('k')) => {
self.action_tx.send(SnowballingAction::PrevItem.into())?;
}
(Tab::Snowballing, KeyCode::Char(' ')) => {
self.action_tx.send(GlobalAction::Fetch.into())?;
}
_ => {}
}

View File

@ -5,9 +5,9 @@ use crate::app::Action;
#[allow(unused_macros)]
#[macro_export]
macro_rules! status_info {
($action_tx:expr, $text:expr, $($args:expr)*) => {
($action_tx:expr, $text:expr $(, $args:expr)*) => {
$action_tx.send(
GlobalAction::ShowStatMsg(StatusMessage::Info(format!($text, $($args)*)))
crate::app::GlobalAction::ShowStatMsg(crate::app::StatusMessage::Info(format!($text, $($args)*)))
.into(),
)
};
@ -16,9 +16,9 @@ macro_rules! status_info {
#[allow(unused_macros)]
#[macro_export]
macro_rules! status_warn {
($action_tx:expr, $text:expr, $($args:expr)*) => {
($action_tx:expr, $text:expr $(, $args:expr)*) => {
$action_tx.send(
GlobalAction::ShowStatMsg(StatusMessage::Warning(format!($text, $($args)*)))
crate::app::GlobalAction::ShowStatMsg(crate::app::StatusMessage::Info(format!($text, $($args)*)))
.into(),
)
};
@ -29,7 +29,7 @@ macro_rules! status_warn {
macro_rules! status_error {
($action_tx:expr, $text:expr $(, $args:expr)*) => {
$action_tx.send(
GlobalAction::ShowStatMsg(StatusMessage::Error(format!($text, $($args)*)))
crate::app::GlobalAction::ShowStatMsg(crate::app::StatusMessage::Info(format!($text, $($args)*)))
.into(),
)
};