From b34839a7935b122f8be988bc05df5a4ce19585d7 Mon Sep 17 00:00:00 2001 From: mostafaei2002 Date: Sat, 15 Jun 2024 13:23:25 +0330 Subject: [PATCH] fix: spare_time being larger than max algo time --- src/helper/xvb/algorithm.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/helper/xvb/algorithm.rs b/src/helper/xvb/algorithm.rs index 4c4e386..eb6455d 100644 --- a/src/helper/xvb/algorithm.rs +++ b/src/helper/xvb/algorithm.rs @@ -74,7 +74,7 @@ pub(crate) fn calcul_donated_time( let mode = lock!(gui_api_xvb).stats_priv.runtime_mode.clone(); let default_spared_time = time_that_could_be_spared(lhr, min_hr); - let spared_time = match mode { + let mut spared_time = match mode { RuntimeMode::Auto => { info!("RuntimeMode::Auto - calculating spared_time"); // calculate how much time needed to be spared to be in most round type minimum HR + buffer @@ -109,6 +109,9 @@ pub(crate) fn calcul_donated_time( }; info!("Final spared_time is {spared_time}"); + if spared_time > XVB_TIME_ALGO { + spared_time = XVB_TIME_ALGO; + } spared_time }