refactor: update AppHandle usage to use Arc<AppHandle> for improved memory management (#4491)

* refactor: update AppHandle usage to use Arc<AppHandle> for improved memory management

* fix: clippy ci

* fix: ensure default_latency_test is safely accessed with non-null assertion
This commit is contained in:
Tunglies
2025-08-23 00:20:58 +08:00
committed by GitHub
parent c416bd5755
commit 0d070fb934
13 changed files with 140 additions and 96 deletions

View File

@@ -11,15 +11,7 @@ use anyhow::{bail, Result};
/// Toggle proxy profile
pub fn toggle_proxy_profile(profile_index: String) {
AsyncHandler::spawn(|| async move {
let Some(app_handle) = handle::Handle::global().app_handle() else {
logging!(
error,
Type::Config,
"Failed to get app handle for profile toggle"
);
return;
};
match cmd::patch_profiles_config_by_profile_index(app_handle, profile_index).await {
match cmd::patch_profiles_config_by_profile_index(profile_index).await {
Ok(_) => {
let _ = tray::Tray::global().update_menu();
}