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::views::{NetworkContent, Root, View};
|
||||
use crate::gui::views::network::types::{NetworkTab, NetworkTabType};
|
||||
use crate::node::Node;
|
||||
use crate::node::{Node, NodeConfig};
|
||||
|
||||
/// Integrated node tab content.
|
||||
#[derive(Default)]
|
||||
|
@ -176,10 +176,10 @@ fn node_stats_ui(ui: &mut egui::Ui) {
|
|||
[false, false, true, false]);
|
||||
});
|
||||
columns[1].vertical_centered(|ui| {
|
||||
View::rounded_box(ui,
|
||||
stats.peer_count.to_string(),
|
||||
t!("network_node.peers"),
|
||||
[false, false, false, true]);
|
||||
let peers_txt = format!("{} ({})",
|
||||
stats.peer_count,
|
||||
NodeConfig::get_max_outbound_peers());
|
||||
View::rounded_box(ui, peers_txt, t!("network_node.peers"), [false, false, false, true]);
|
||||
});
|
||||
});
|
||||
ui.add_space(5.0);
|
||||
|
|
|
@ -637,7 +637,7 @@ impl View {
|
|||
};
|
||||
// Show application logo and name.
|
||||
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")
|
||||
.size(24.0)
|
||||
.color(Colors::white_or_black(true))
|
||||
|
|
|
@ -341,11 +341,19 @@ impl WalletsContent {
|
|||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
// Show application logo and name.
|
||||
View::app_logo_name_version(ui);
|
||||
ui.add_space(20.0);
|
||||
ui.add_space(15.0);
|
||||
|
||||
let mut list = self.wallets.list().clone();
|
||||
// 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 {
|
||||
// Check if wallet reopen is 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_ready = Node::get_sync_status() == Some(SyncStatus::NoSync);
|
||||
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"))
|
||||
.size(16.0)
|
||||
.color(Colors::red()));
|
||||
ui.add_space(2.0);
|
||||
} else if !wallet.is_repairing() {
|
||||
ui.add_space(6.0);
|
||||
|
||||
|
|
|
@ -89,16 +89,16 @@ impl WalletList {
|
|||
list.insert(0, wallet);
|
||||
}
|
||||
|
||||
// /// Remove [`Wallet`] with provided identifier.
|
||||
// pub fn remove(&mut self, id: i64) {
|
||||
// let list = self.mut_list();
|
||||
// for (index, wallet) in list.iter().enumerate() {
|
||||
// if wallet.get_config().id == id {
|
||||
// list.remove(index);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/// Remove [`Wallet`] with provided identifier.
|
||||
pub fn remove(&mut self, id: i64) {
|
||||
let list = self.mut_list();
|
||||
for (index, wallet) in list.iter().enumerate() {
|
||||
if wallet.get_config().id == id {
|
||||
list.remove(index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Select [`Wallet`] with provided identifier.
|
||||
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.
|
||||
pub fn delete_wallet(&self) {
|
||||
let wallet_delete = self.clone();
|
||||
// Close wallet if open.
|
||||
if self.is_open() {
|
||||
self.close();
|
||||
}
|
||||
// Mark wallet as deleted.
|
||||
let wallet_delete = self.clone();
|
||||
wallet_delete.deleted.store(true, Ordering::Relaxed);
|
||||
|
||||
thread::spawn(move || {
|
||||
// Wait wallet to be closed.
|
||||
if wallet_delete.is_open() {
|
||||
thread::sleep(Duration::from_millis(300));
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
// Remove wallet files.
|
||||
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);
|
||||
// Start sync to close thread.
|
||||
wallet_delete.sync(true);
|
||||
|
|
Loading…
Reference in a new issue