Skip to content

Commit

Permalink
chore(launchpad): update text and logic for reset if discord_id change
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Jun 4, 2024
1 parent 0cbad37 commit d51ef5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions node-launchpad/src/components/beta_programme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl Component for BetaProgramme {
);
f.render_widget(input, layer_two[1]);

let text = Paragraph::new(" Changing the username will lead to loss of earned.\n rewards. The nodes will be restarted to reflect\n the change.");
let text = Paragraph::new(" Changing your Username will reset all nodes,\n and any Nanos left on this device will be\n lost.");
f.render_widget(text.fg(GHOST_WHITE), layer_two[2]);

let dash = Block::new()
Expand All @@ -240,8 +240,8 @@ impl Component for BetaProgramme {
f.render_widget(dash, layer_two[3]);

let buttons_layer = Layout::horizontal(vec![
Constraint::Percentage(50),
Constraint::Percentage(50),
Constraint::Percentage(55),
Constraint::Percentage(45),
])
.split(layer_two[4]);

Expand All @@ -257,7 +257,7 @@ impl Component for BetaProgramme {
Style::default().fg(EUCALYPTUS)
};
let button_yes = Line::from(vec![Span::styled(
"Modify Username [Enter]",
"Save Username [Enter]",
button_yes_style,
)]);
f.render_widget(button_yes, buttons_layer[1]);
Expand Down
14 changes: 10 additions & 4 deletions node-launchpad/src/components/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,20 @@ impl Component for Home {
}
}
Action::StoreDiscordUserName(username) => {
let reset_safenode_services = (self.discord_username != username)
&& !self.discord_username.is_empty()
&& !self.node_services.is_empty();
let has_changed = self.discord_username != username;
let is_old_discord_username_empty = self.discord_username.is_empty();
let we_have_nodes = !self.node_services.is_empty();

let reset_old_nodes_with_no_id =
we_have_nodes && is_old_discord_username_empty && has_changed;
let reset_nodes_to_new_id = has_changed && !is_old_discord_username_empty;

self.discord_username = username;
trace!(%is_old_discord_username_empty, %we_have_nodes, %has_changed, %reset_old_nodes_with_no_id, %reset_nodes_to_new_id, "Discord username state");

// todo: The discord_username popup should warn people that if nodes are running, they will be reset.
// And the earnings will be lost.
if reset_safenode_services {
if reset_old_nodes_with_no_id || reset_nodes_to_new_id {
self.lock_registry = Some(LockRegistryState::ResettingNodes);
info!("Resetting safenode services because the discord username was reset.");
let action_sender = self.get_actions_sender()?;
Expand Down

0 comments on commit d51ef5c

Please sign in to comment.