diff --git a/gui/src/app/state/mod.rs b/gui/src/app/state/mod.rs index 97392b44..ca70cf82 100644 --- a/gui/src/app/state/mod.rs +++ b/gui/src/app/state/mod.rs @@ -75,6 +75,7 @@ pub struct Home { pending_events: Vec, events: Vec, is_last_page: bool, + processing: bool, selected_event: Option<(usize, usize)>, labels_edited: LabelsEdited, warning: Option, @@ -106,6 +107,7 @@ impl Home { labels_edited: LabelsEdited::default(), warning: None, is_last_page: false, + processing: false, } } } @@ -138,6 +140,7 @@ impl State for Home { &self.pending_events, &self.events, self.is_last_page, + self.processing, ), ) } @@ -196,6 +199,7 @@ impl State for Home { Message::HistoryTransactionsExtension(res) => match res { Err(e) => self.warning = Some(e), Ok(events) => { + self.processing = false; self.warning = None; self.is_last_page = (events.len() as u64) < HISTORY_EVENT_PAGE_SIZE; for event in events { @@ -243,6 +247,7 @@ impl State for Home { if let Some(last) = self.events.last() { let daemon = daemon.clone(); let last_event_date = last.time.unwrap(); + self.processing = true; return Command::perform( async move { let mut limit = HISTORY_EVENT_PAGE_SIZE; diff --git a/gui/src/app/state/transactions.rs b/gui/src/app/state/transactions.rs index bb9e3eec..e0e15e6f 100644 --- a/gui/src/app/state/transactions.rs +++ b/gui/src/app/state/transactions.rs @@ -44,6 +44,7 @@ pub struct TransactionsPanel { warning: Option, create_rbf_modal: Option, is_last_page: bool, + processing: bool, } impl TransactionsPanel { @@ -57,6 +58,7 @@ impl TransactionsPanel { warning: None, create_rbf_modal: None, is_last_page: false, + processing: false, } } @@ -88,6 +90,7 @@ impl State for TransactionsPanel { &self.txs, self.warning.as_ref(), self.is_last_page, + self.processing, ) } } @@ -111,6 +114,7 @@ impl State for TransactionsPanel { Message::HistoryTransactionsExtension(res) => match res { Err(e) => self.warning = Some(e), Ok(txs) => { + self.processing = false; self.warning = None; self.is_last_page = (txs.len() as u64) < HISTORY_EVENT_PAGE_SIZE; for tx in txs { @@ -217,6 +221,7 @@ impl State for TransactionsPanel { if let Some(last) = self.txs.last() { let daemon = daemon.clone(); let last_tx_date = last.time.unwrap(); + self.processing = true; return Command::perform( async move { let mut limit = HISTORY_EVENT_PAGE_SIZE; diff --git a/gui/src/app/view/home.rs b/gui/src/app/view/home.rs index 235eb4ce..eedc70d6 100644 --- a/gui/src/app/view/home.rs +++ b/gui/src/app/view/home.rs @@ -21,6 +21,7 @@ use crate::{ daemon::model::{HistoryTransaction, TransactionKind}, }; +#[allow(clippy::too_many_arguments)] pub fn home_view<'a>( balance: &'a bitcoin::Amount, unconfirmed_balance: &'a bitcoin::Amount, @@ -29,6 +30,7 @@ pub fn home_view<'a>( pending_events: &'a [HistoryTransaction], events: &'a [HistoryTransaction], is_last_page: bool, + processing: bool, ) -> Element<'a, Message> { Column::new() .push(h3("Balance")) @@ -122,14 +124,22 @@ pub fn home_view<'a>( Some( Container::new( Button::new( - text("See more") - .width(Length::Fill) - .horizontal_alignment(alignment::Horizontal::Center), + text(if processing { + "Fetching ..." + } else { + "See more" + }) + .width(Length::Fill) + .horizontal_alignment(alignment::Horizontal::Center), ) .width(Length::Fill) .padding(15) .style(theme::Button::TransparentBorder) - .on_press(Message::Next), + .on_press_maybe(if !processing { + Some(Message::Next) + } else { + None + }), ) .width(Length::Fill) .style(theme::Container::Card(theme::Card::Simple)), diff --git a/gui/src/app/view/transactions.rs b/gui/src/app/view/transactions.rs index e1958f91..0b2a5d12 100644 --- a/gui/src/app/view/transactions.rs +++ b/gui/src/app/view/transactions.rs @@ -26,6 +26,7 @@ pub fn transactions_view<'a>( txs: &'a [HistoryTransaction], warning: Option<&'a Error>, is_last_page: bool, + processing: bool, ) -> Element<'a, Message> { dashboard( &Menu::Transactions, @@ -59,14 +60,22 @@ pub fn transactions_view<'a>( Some( Container::new( Button::new( - text("See more") - .width(Length::Fill) - .horizontal_alignment(alignment::Horizontal::Center), + text(if processing { + "Fetching ..." + } else { + "See more" + }) + .width(Length::Fill) + .horizontal_alignment(alignment::Horizontal::Center), ) .width(Length::Fill) .padding(15) .style(theme::Button::TransparentBorder) - .on_press(Message::Next), + .on_press_maybe(if !processing { + Some(Message::Next) + } else { + None + }), ) .width(Length::Fill) .style(theme::Container::Card(theme::Card::Simple)),