From f2d0c9a288a0ea8f86930619fd148052fafb3c8b Mon Sep 17 00:00:00 2001 From: Louis-Marie Baer Date: Wed, 13 Mar 2024 10:02:50 +0100 Subject: [PATCH] feat: warn user in XvB tab if no address is set in P2pool Tab --- src/app/panels/middle/mod.rs | 2 +- src/app/panels/middle/xvb.rs | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/app/panels/middle/mod.rs b/src/app/panels/middle/mod.rs index a8b2acb..9c68888 100644 --- a/src/app/panels/middle/mod.rs +++ b/src/app/panels/middle/mod.rs @@ -161,7 +161,7 @@ path_xmr: {:#?}\n } Tab::Xvb => { debug!("App | Entering [XvB] Tab"); - crate::disk::state::Xvb::show(&mut self.state.xvb, self.size, ctx, ui, &self.xvb_api); + crate::disk::state::Xvb::show(&mut self.state.xvb, self.size, &self.state.p2pool.address, ctx, ui, &self.xvb_api); } } }); diff --git a/src/app/panels/middle/xvb.rs b/src/app/panels/middle/xvb.rs index 81265de..7c07cb6 100644 --- a/src/app/panels/middle/xvb.rs +++ b/src/app/panels/middle/xvb.rs @@ -5,8 +5,9 @@ use egui::{Hyperlink, Image, Label, RichText, TextEdit, Vec2}; use log::debug; use crate::helper::xvb::PubXvbApi; -use crate::utils::constants::{GREEN, LIGHT_GRAY, RED, XVB_HELP, XVB_TOKEN_LEN}; +use crate::utils::constants::{GREEN, LIGHT_GRAY, ORANGE, RED, XVB_HELP, XVB_TOKEN_LEN}; use crate::utils::macros::lock; +use crate::utils::regex::Regexes; use crate::{ constants::{BYTES_XVB, SPACE}, utils::constants::{DARK_GRAY, XVB_URL}, @@ -17,6 +18,7 @@ impl crate::disk::state::Xvb { pub fn show( &mut self, size: Vec2, + address: &str, _ctx: &egui::Context, ui: &mut egui::Ui, api: &Arc>, @@ -82,11 +84,20 @@ impl crate::disk::state::Xvb { ui.add_sized( [width / 8.0, text_edit], TextEdit::singleline(&mut self.token), - ) - .on_hover_text_at_pointer(XVB_HELP); + ); + ui.add(Label::new(RichText::new(text_check).color(color))) }); - }); + }) + .response + .on_hover_text_at_pointer(XVB_HELP); // need to warn the user if no address is set in p2pool tab + if !Regexes::addr_ok(address) { + debug!("XvB Tab | Rendering warning text"); + ui.label(RichText::new("You don't have any payout address set in the P2pool Tab !\nXvB process needs one to function properly.") + .color(ORANGE)); + } + // hero option + // private stats } }