Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(launchpad): change copy on popup estimated time #2411

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
mazzi marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -53,6 +53,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 @@ -657,7 +658,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
Loading