ui: fix wallet deletion, node info max peers amount, paddings at logo and wallet recovery settings
This commit is contained in:
parent
b78ba0bfb5
commit
538ff37056
6 changed files with 34 additions and 23 deletions
|
@ -21,7 +21,7 @@ use crate::gui::icons::{AT, CUBE, DEVICES, FLOW_ARROW, HANDSHAKE, PACKAGE, SHARE
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
use crate::gui::views::{NetworkContent, Root, View};
|
use crate::gui::views::{NetworkContent, Root, View};
|
||||||
use crate::gui::views::network::types::{NetworkTab, NetworkTabType};
|
use crate::gui::views::network::types::{NetworkTab, NetworkTabType};
|
||||||
use crate::node::Node;
|
use crate::node::{Node, NodeConfig};
|
||||||
|
|
||||||
/// Integrated node tab content.
|
/// Integrated node tab content.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -176,10 +176,10 @@ fn node_stats_ui(ui: &mut egui::Ui) {
|
||||||
[false, false, true, false]);
|
[false, false, true, false]);
|
||||||
});
|
});
|
||||||
columns[1].vertical_centered(|ui| {
|
columns[1].vertical_centered(|ui| {
|
||||||
View::rounded_box(ui,
|
let peers_txt = format!("{} ({})",
|
||||||
stats.peer_count.to_string(),
|
stats.peer_count,
|
||||||
t!("network_node.peers"),
|
NodeConfig::get_max_outbound_peers());
|
||||||
[false, false, false, true]);
|
View::rounded_box(ui, peers_txt, t!("network_node.peers"), [false, false, false, true]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
|
|
|
@ -637,7 +637,7 @@ impl View {
|
||||||
};
|
};
|
||||||
// Show application logo and name.
|
// Show application logo and name.
|
||||||
egui::Image::new(logo).fit_to_exact_size(egui::vec2(180.0, 180.0)).ui(ui);
|
egui::Image::new(logo).fit_to_exact_size(egui::vec2(180.0, 180.0)).ui(ui);
|
||||||
ui.add_space(-17.0);
|
ui.add_space(-12.0);
|
||||||
ui.label(RichText::new("GRIM")
|
ui.label(RichText::new("GRIM")
|
||||||
.size(24.0)
|
.size(24.0)
|
||||||
.color(Colors::white_or_black(true))
|
.color(Colors::white_or_black(true))
|
||||||
|
|
|
@ -341,11 +341,19 @@ impl WalletsContent {
|
||||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||||
// Show application logo and name.
|
// Show application logo and name.
|
||||||
View::app_logo_name_version(ui);
|
View::app_logo_name_version(ui);
|
||||||
ui.add_space(20.0);
|
ui.add_space(15.0);
|
||||||
|
|
||||||
let mut list = self.wallets.list().clone();
|
let mut list = self.wallets.list().clone();
|
||||||
// Remove deleted wallet from the list.
|
// Remove deleted wallet from the list.
|
||||||
list.retain(|w| !w.is_deleted());
|
list.retain(|w| {
|
||||||
|
let deleted = w.is_deleted();
|
||||||
|
if deleted {
|
||||||
|
self.wallets.select(None);
|
||||||
|
self.wallets.remove(w.get_config().id);
|
||||||
|
ui.ctx().request_repaint();
|
||||||
|
}
|
||||||
|
!deleted
|
||||||
|
});
|
||||||
for wallet in &list {
|
for wallet in &list {
|
||||||
// Check if wallet reopen is needed.
|
// Check if wallet reopen is needed.
|
||||||
if !wallet.is_open() && wallet.reopen_needed() {
|
if !wallet.is_open() && wallet.reopen_needed() {
|
||||||
|
|
|
@ -70,10 +70,11 @@ impl RecoverySetup {
|
||||||
let integrated_node = wallet.get_current_ext_conn().is_none();
|
let integrated_node = wallet.get_current_ext_conn().is_none();
|
||||||
let integrated_node_ready = Node::get_sync_status() == Some(SyncStatus::NoSync);
|
let integrated_node_ready = Node::get_sync_status() == Some(SyncStatus::NoSync);
|
||||||
if wallet.sync_error() || (integrated_node && !integrated_node_ready) {
|
if wallet.sync_error() || (integrated_node && !integrated_node_ready) {
|
||||||
ui.add_space(6.0);
|
ui.add_space(2.0);
|
||||||
ui.label(RichText::new(t!("wallets.repair_unavailable"))
|
ui.label(RichText::new(t!("wallets.repair_unavailable"))
|
||||||
.size(16.0)
|
.size(16.0)
|
||||||
.color(Colors::red()));
|
.color(Colors::red()));
|
||||||
|
ui.add_space(2.0);
|
||||||
} else if !wallet.is_repairing() {
|
} else if !wallet.is_repairing() {
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
|
|
||||||
|
|
|
@ -89,16 +89,16 @@ impl WalletList {
|
||||||
list.insert(0, wallet);
|
list.insert(0, wallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// Remove [`Wallet`] with provided identifier.
|
/// Remove [`Wallet`] with provided identifier.
|
||||||
// pub fn remove(&mut self, id: i64) {
|
pub fn remove(&mut self, id: i64) {
|
||||||
// let list = self.mut_list();
|
let list = self.mut_list();
|
||||||
// for (index, wallet) in list.iter().enumerate() {
|
for (index, wallet) in list.iter().enumerate() {
|
||||||
// if wallet.get_config().id == id {
|
if wallet.get_config().id == id {
|
||||||
// list.remove(index);
|
list.remove(index);
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
/// Select [`Wallet`] with provided identifier.
|
/// Select [`Wallet`] with provided identifier.
|
||||||
pub fn select(&mut self, id: Option<i64>) {
|
pub fn select(&mut self, id: Option<i64>) {
|
||||||
|
|
|
@ -1018,19 +1018,21 @@ impl Wallet {
|
||||||
|
|
||||||
/// Close the wallet, delete its files and mark it as deleted.
|
/// Close the wallet, delete its files and mark it as deleted.
|
||||||
pub fn delete_wallet(&self) {
|
pub fn delete_wallet(&self) {
|
||||||
let wallet_delete = self.clone();
|
|
||||||
// Close wallet if open.
|
|
||||||
if self.is_open() {
|
if self.is_open() {
|
||||||
self.close();
|
self.close();
|
||||||
}
|
}
|
||||||
|
// Mark wallet as deleted.
|
||||||
|
let wallet_delete = self.clone();
|
||||||
|
wallet_delete.deleted.store(true, Ordering::Relaxed);
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
// Wait wallet to be closed.
|
// Wait wallet to be closed.
|
||||||
if wallet_delete.is_open() {
|
if wallet_delete.is_open() {
|
||||||
thread::sleep(Duration::from_millis(300));
|
thread::sleep(Duration::from_millis(100));
|
||||||
}
|
}
|
||||||
// Remove wallet files.
|
// Remove wallet files.
|
||||||
let _ = fs::remove_dir_all(wallet_delete.get_config().get_data_path());
|
let _ = fs::remove_dir_all(wallet_delete.get_config().get_data_path());
|
||||||
// Mark wallet as not opened and deleted.
|
// Mark wallet as deleted.
|
||||||
wallet_delete.deleted.store(true, Ordering::Relaxed);
|
wallet_delete.deleted.store(true, Ordering::Relaxed);
|
||||||
// Start sync to close thread.
|
// Start sync to close thread.
|
||||||
wallet_delete.sync(true);
|
wallet_delete.sync(true);
|
||||||
|
|
Loading…
Reference in a new issue