Prevent ingestions being logged twice bc i'm stoopid

This commit is contained in:
xqtc 2024-10-10 22:50:56 +02:00
parent 519f3d2165
commit 28ba4e988f

View file

@ -89,7 +89,7 @@ pub fn add_ingestion() {
.with_help_message("Use the format YYYY-MM-DD HH:MM") .with_help_message("Use the format YYYY-MM-DD HH:MM")
.prompt() .prompt()
.unwrap(); .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( let dose_unit = inquire::Select::new(
"What unit should be used?", "What unit should be used?",
DoseUnit::iter().collect::<Vec<_>>(), DoseUnit::iter().collect::<Vec<_>>(),
@ -107,9 +107,6 @@ pub fn add_ingestion() {
ingest_method: ingestion_method_select, ingest_method: ingestion_method_select,
time: date_time, 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!( println!(
"Substance: {} ({})\nDose: {}{}\nTime: {}\n", "Substance: {} ({})\nDose: {}{}\nTime: {}\n",
ingestion.substance, ingestion.substance,
@ -120,6 +117,7 @@ pub fn add_ingestion() {
); );
let confirm = let confirm =
inquire::prompt_confirmation("Does the ingestion above look alright? [y/N]").unwrap(); inquire::prompt_confirmation("Does the ingestion above look alright? [y/N]").unwrap();
dbg!(&confirm);
if confirm { if confirm {
ingesstions_bytes_loaded_des.insert(Uuid::new_v4(), ingestion.clone()); ingesstions_bytes_loaded_des.insert(Uuid::new_v4(), ingestion.clone());
let ingestion_ser = bincode::serialize(&ingesstions_bytes_loaded_des).unwrap(); let ingestion_ser = bincode::serialize(&ingesstions_bytes_loaded_des).unwrap();