From 28ba4e988f7da9e91dee8cf8f485ba6e798d34d4 Mon Sep 17 00:00:00 2001 From: xqtc Date: Thu, 10 Oct 2024 22:50:56 +0200 Subject: [PATCH] Prevent ingestions being logged twice bc i'm stoopid --- src/ingestions.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ingestions.rs b/src/ingestions.rs index 308c806..9e3d16a 100644 --- a/src/ingestions.rs +++ b/src/ingestions.rs @@ -89,7 +89,7 @@ pub fn add_ingestion() { .with_help_message("Use the format YYYY-MM-DD HH:MM") .prompt() .unwrap(); - let dose_num: f64 = inquire::prompt_f64("Enter the amount consumed").unwrap(); + let dose_num: f64 = inquire::prompt_f64("Enter the amount consumed:").unwrap(); let dose_unit = inquire::Select::new( "What unit should be used?", DoseUnit::iter().collect::>(), @@ -107,9 +107,6 @@ pub fn add_ingestion() { ingest_method: ingestion_method_select, time: date_time, }; - ingesstions_bytes_loaded_des.insert(Uuid::new_v4(), ingestion.clone()); - let ingestion_ser = bincode::serialize(&ingesstions_bytes_loaded_des).unwrap(); - std::fs::write(INGESTIONS_FILE.to_string(), ingestion_ser); println!( "Substance: {} ({})\nDose: {}{}\nTime: {}\n", ingestion.substance, @@ -120,6 +117,7 @@ pub fn add_ingestion() { ); let confirm = inquire::prompt_confirmation("Does the ingestion above look alright? [y/N]").unwrap(); + dbg!(&confirm); if confirm { ingesstions_bytes_loaded_des.insert(Uuid::new_v4(), ingestion.clone()); let ingestion_ser = bincode::serialize(&ingesstions_bytes_loaded_des).unwrap();