From 2e942a9b31edec51c970a01427639aa950bd1ac4 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Wed, 31 Dec 2025 03:01:19 +0200 Subject: [PATCH] Add App::fetch function; Fix macros --- src/app.rs | 24 ++++++++++++++++++------ src/app/common.rs | 10 +++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index 0a6750d..fc9f821 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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> { + // 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, + ) -> Result<(), SendError> { + 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())?; + } _ => {} } diff --git a/src/app/common.rs b/src/app/common.rs index ffd5a38..741a757 100644 --- a/src/app/common.rs +++ b/src/app/common.rs @@ -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(), ) };