Skip to content
Snippets Groups Projects
Commit 579f36a1 authored by GyDi's avatar GyDi
Browse files

fix: update profile after restart clash

parent 72c2b306
No related branches found
No related tags found
No related merge requests found
......@@ -142,10 +142,27 @@ pub fn patch_profile(
/// restart the sidecar
#[tauri::command]
pub fn restart_sidecar(clash_state: State<'_, ClashState>) {
let mut clash_arc = clash_state.0.lock().unwrap();
if let Err(err) = clash_arc.restart_sidecar() {
log::error!("{}", err);
pub fn restart_sidecar(
clash_state: State<'_, ClashState>,
profiles_state: State<'_, ProfilesState>,
) -> Result<(), String> {
let mut clash = clash_state.0.lock().unwrap();
match clash.restart_sidecar() {
Ok(_) => {
let profiles = profiles_state.0.lock().unwrap();
match profiles.activate(clash.info.clone()) {
Ok(()) => Ok(()),
Err(err) => {
log::error!("{}", err);
Err(err)
}
}
}
Err(err) => {
log::error!("{}", err);
Err(err)
}
}
}
......
......@@ -42,9 +42,16 @@ fn main() -> std::io::Result<()> {
}
"restart_clash" => {
let clash_state = app_handle.state::<states::ClashState>();
let mut clash_arc = clash_state.0.lock().unwrap();
if let Err(err) = clash_arc.restart_sidecar() {
log::error!("{}", err);
let mut clash = clash_state.0.lock().unwrap();
match clash.restart_sidecar() {
Ok(_) => {
let profiles = app_handle.state::<states::ProfilesState>();
let profiles = profiles.0.lock().unwrap();
if let Err(err) = profiles.activate(clash.info.clone()) {
log::error!("{}", err);
}
}
Err(err) => log::error!("{}", err),
}
}
"quit" => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment