From 4942b0fca5c6859a6e729afc28f6009aed02412c Mon Sep 17 00:00:00 2001 From: GyDi Date: Mon, 8 Aug 2022 23:17:22 +0800 Subject: [PATCH] fix: save profile when update --- src-tauri/src/cmds.rs | 4 ++-- src-tauri/src/core/profiles.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/cmds.rs b/src-tauri/src/cmds.rs index 0fcd861..ec00eeb 100644 --- a/src-tauri/src/cmds.rs +++ b/src-tauri/src/cmds.rs @@ -76,7 +76,7 @@ pub fn select_profile(index: String, core: State<'_, Core>) -> CmdResult { #[tauri::command] pub fn change_profile_chain(chain: Option>, core: State<'_, Core>) -> CmdResult { let mut profiles = core.profiles.lock(); - profiles.put_chain(chain); + wrap_err!(profiles.put_chain(chain))?; drop(profiles); @@ -87,7 +87,7 @@ pub fn change_profile_chain(chain: Option>, core: State<'_, Core>) - #[tauri::command] pub fn change_profile_valid(valid: Option>, core: State) -> CmdResult { let mut profiles = core.profiles.lock(); - profiles.put_valid(valid); + wrap_err!(profiles.put_valid(valid))?; drop(profiles); diff --git a/src-tauri/src/core/profiles.rs b/src-tauri/src/core/profiles.rs index 60f1a9a..9116e9a 100644 --- a/src-tauri/src/core/profiles.rs +++ b/src-tauri/src/core/profiles.rs @@ -91,13 +91,15 @@ impl Profiles { } /// just change the `chain` - pub fn put_chain(&mut self, chain: Option>) { + pub fn put_chain(&mut self, chain: Option>) -> Result<()> { self.chain = chain; + self.save_file() } /// just change the `field` - pub fn put_valid(&mut self, valid: Option>) { + pub fn put_valid(&mut self, valid: Option>) -> Result<()> { self.valid = valid; + self.save_file() } /// get items ref