diff --git a/src/action.rs b/src/action.rs
index 4ec55ba..44f43d9 100644
--- a/src/action.rs
+++ b/src/action.rs
@@ -29,6 +29,9 @@ pub enum Action {
UsedAccount(AccountId32),
NewAccount(String),
+ RenameAccount(String),
+ UpdateAccountName(String),
+
NewBestBlock(u32),
NewBestHash(H256),
NewFinalizedBlock(u32),
diff --git a/src/components/wallet/accounts.rs b/src/components/wallet/accounts.rs
index f3451f8..bc60e75 100644
--- a/src/components/wallet/accounts.rs
+++ b/src/components/wallet/accounts.rs
@@ -72,6 +72,23 @@ impl Accounts {
self.save_to_file();
}
+ fn rename_account(&mut self, new_name: String) {
+ if let Some(index) = self.table_state.selected() {
+ self.wallet_keys[index].0 = new_name;
+ self.save_to_file();
+ }
+ }
+
+ fn update_account_name(&mut self) {
+ if let Some(index) = self.table_state.selected() {
+ if let Some(action_tx) = &self.action_tx {
+ let _ = action_tx.send(Action::RenameAccount(
+ self.wallet_keys[index].0.clone()
+ ));
+ }
+ }
+ }
+
fn swap_up(&mut self) {
if let Some(src_index) = self.table_state.selected() {
let dst_index = src_index.saturating_sub(1);
@@ -231,11 +248,7 @@ impl PartialComponent for Accounts {
fn set_active(&mut self, current_tab: CurrentTab) {
match current_tab {
CurrentTab::Accounts => self.is_active = true,
- _ => {
- self.is_active = false;
- self.table_state.select(None);
- self.scroll_state = self.scroll_state.position(0);
- }
+ _ => self.is_active = false,
}
}
}
@@ -269,6 +282,7 @@ impl Component for Accounts {
fn update(&mut self, action: Action) -> Result