Skip to content

Commit

Permalink
Merge pull request #2411 from mazzi/fix_modify_copy
Browse files Browse the repository at this point in the history
fix(launchpad): change copy on popup estimated time
  • Loading branch information
jacderida authored Nov 7, 2024
2 parents 5bab4e6 + 07ece14 commit 6a4513f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion node-launchpad/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl App {
let change_connection_mode = ChangeConnectionModePopUp::new(connection_mode)?;
let port_range = PortRangePopUp::new(connection_mode, port_from, port_to);
let rewards_address = RewardsAddress::new(app_data.discord_username.clone());
let upgrade_nodes = UpgradeNodesPopUp::default();
let upgrade_nodes = UpgradeNodesPopUp::new(app_data.nodes_to_start);

Ok(Self {
config,
Expand Down
29 changes: 20 additions & 9 deletions node-launchpad/src/components/popup/upgrade_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::super::utils::centered_rect_fixed;
use super::super::Component;
use crate::{
action::{Action, OptionsActions},
components::status,
mode::{InputMode, Scene},
style::{clear_area, EUCALYPTUS, GHOST_WHITE, LIGHT_PERIWINKLE, VIVID_SKY_BLUE},
};
Expand All @@ -18,19 +19,17 @@ use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{prelude::*, widgets::*};

pub struct UpgradeNodesPopUp {
nodes_to_start: usize,
/// Whether the component is active right now, capturing keystrokes + draw things.
active: bool,
}

impl UpgradeNodesPopUp {
pub fn new() -> Self {
Self { active: false }
}
}

impl Default for UpgradeNodesPopUp {
fn default() -> Self {
Self::new()
pub fn new(nodes_to_start: usize) -> Self {
Self {
nodes_to_start,
active: false,
}
}
}

Expand Down Expand Up @@ -69,6 +68,10 @@ impl Component for UpgradeNodesPopUp {
None
}
},
Action::StoreNodesToStart(ref nodes_to_start) => {
self.nodes_to_start = *nodes_to_start;
None
}
_ => None,
};
Ok(send_back)
Expand Down Expand Up @@ -133,7 +136,15 @@ impl Component for UpgradeNodesPopUp {
"No data will be lost.",
Style::default().fg(LIGHT_PERIWINKLE),
)),
Line::from(Span::styled("\n\n", Style::default())),
Line::from(Span::styled(
format!(
"Upgrade time ~ {:.1?} mins ({:?} nodes * {:?} secs)",
self.nodes_to_start * (status::FIXED_INTERVAL / 1_000) as usize / 60,
self.nodes_to_start,
status::FIXED_INTERVAL / 1_000,
),
Style::default().fg(LIGHT_PERIWINKLE),
)),
Line::from(Span::styled("\n\n", Style::default())),
Line::from(vec![
Span::styled("You’ll need to ", Style::default().fg(LIGHT_PERIWINKLE)),
Expand Down
3 changes: 2 additions & 1 deletion node-launchpad/src/components/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ use super::super::node_mgmt::{maintain_n_running_nodes, reset_nodes, stop_nodes}

use throbber_widgets_tui::{self, Throbber, ThrobberState};

pub const FIXED_INTERVAL: u64 = 60_000;
pub const NODE_STAT_UPDATE_INTERVAL: Duration = Duration::from_secs(5);
/// If nat detection fails for more than 3 times, we don't want to waste time running during every node start.
const MAX_ERRORS_WHILE_RUNNING_NAT_DETECTION: usize = 3;
Expand Down Expand Up @@ -671,7 +672,7 @@ impl Component for Status<'_> {
do_not_start: true,
custom_bin_path: None,
force: false,
fixed_interval: Some(300_000), // 5 mins in millis
fixed_interval: Some(FIXED_INTERVAL),
peer_ids,
provided_env_variables: None,
service_names,
Expand Down

0 comments on commit 6a4513f

Please sign in to comment.