From e1ba63e0d2a7f695d58affc87be7b0c5b260e8b6 Mon Sep 17 00:00:00 2001 From: Cyrix126 Date: Sat, 2 Nov 2024 16:42:33 +0100 Subject: [PATCH] fix: simple mode hero not taken into account --- src/app/mod.rs | 10 +++++++++- src/app/panels/middle/xvb.rs | 10 ++++------ src/helper/xvb/mod.rs | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index 0cd5a51..7d9ac27 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -22,6 +22,7 @@ use crate::helper::p2pool::PubP2poolApi; use crate::helper::xrig::xmrig::ImgXmrig; use crate::helper::xrig::xmrig::PubXmrigApi; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi; +use crate::helper::xvb::priv_stats::RuntimeMode; use crate::helper::xvb::PubXvbApi; use crate::helper::Helper; use crate::helper::Process; @@ -596,7 +597,14 @@ impl App { // Set saved Hero mode to runtime. debug!("Setting runtime_mode & runtime_manual_amount"); - app.xvb_api.lock().unwrap().stats_priv.runtime_mode = app.state.xvb.mode.clone().into(); + // apply hero if simple mode saved with checkbox true, will let default to auto otherwise + if app.state.xvb.simple { + if app.state.xvb.simple_hero_mode { + app.xvb_api.lock().unwrap().stats_priv.runtime_mode = RuntimeMode::Hero + } + } else { + app.xvb_api.lock().unwrap().stats_priv.runtime_mode = app.state.xvb.mode.clone().into(); + } app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount = app.state.xvb.manual_amount_raw; // Check if [P2pool.node] exists diff --git a/src/app/panels/middle/xvb.rs b/src/app/panels/middle/xvb.rs index 74e373a..5642af2 100644 --- a/src/app/panels/middle/xvb.rs +++ b/src/app/panels/middle/xvb.rs @@ -129,15 +129,13 @@ impl crate::disk::state::Xvb { ui.style_mut().spacing.icon_spacing = space_h; // --------------------------- XVB Simple ------------------------------------------- - if self.simple { - - if ui.checkbox(&mut self.simple_hero_mode, "Hero Mode").on_hover_text(XVB_HERO_SELECT).clicked() { - // also change hero mode of runtime. + if self.simple && ui.checkbox(&mut self.simple_hero_mode, "Hero Mode").on_hover_text(XVB_HERO_SELECT).clicked() { + // change rutime mode immediatly. + if self.simple_hero_mode { api.lock().unwrap().stats_priv.runtime_mode = RuntimeMode::Hero; - } else { + } else { api.lock().unwrap().stats_priv.runtime_mode = RuntimeMode::Auto; } - } }); diff --git a/src/helper/xvb/mod.rs b/src/helper/xvb/mod.rs index ca48cfc..11f7c55 100644 --- a/src/helper/xvb/mod.rs +++ b/src/helper/xvb/mod.rs @@ -822,6 +822,7 @@ fn signal_interrupt( } fn reset_data_xvb(pub_api: &Arc>, gui_api: &Arc>) { let current_node = mem::take(&mut pub_api.lock().unwrap().current_node.clone()); + // even if it is a restart, we want to keep set values by the user without the need from him to click on save button. let runtime_mode = mem::take(&mut gui_api.lock().unwrap().stats_priv.runtime_mode); let runtime_manual_amount = mem::take(&mut gui_api.lock().unwrap().stats_priv.runtime_manual_amount);