From c7edd0dbb1641b0e45e3068ca71c2fb8ca22b3cb Mon Sep 17 00:00:00 2001 From: Finn Brewer Date: Tue, 23 Jul 2024 22:04:54 -0700 Subject: [PATCH] fix: saving out of date definitions --- src-tauri/src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ec81afb..4615796 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -422,6 +422,20 @@ async fn write_settings( let conts = toml::to_string_pretty(&settings)?; let mut state = state.0.lock().await; + + // TODO: avoid this clone (arc) + let cloned_languages = state.settings.languages.clone(); + + for (language, specific_settings) in &cloned_languages { + if let Some(new_specific_settings) = settings.languages.get(language) { + if new_specific_settings.dicts != specific_settings.dicts { + if let Some(saved_details) = state.to_save.language_specific.get_mut(language) { + saved_details.cached_defs.clear(); + } + } + } + } + state.settings = settings; fs::write(config_file, conts)?;