refactor: replace async runtime with blocking thread for tray menu refresh and mark unused state parameter
Replace tauri::async_runtime::spawn with std::thread::spawn for periodic tray menu refresh background task and change async sleep to blocking thread sleep. Prefix unused state parameter with underscore in sync_profile command to suppress compiler warnings.
This commit is contained in:
@@ -264,7 +264,7 @@ fn clear_session(app: AppHandle, state: State<'_, AppState>) -> Result<(), Strin
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn sync_profile(app: AppHandle, state: State<'_, AppState>) -> Result<EnrollmentResult, String> {
|
||||
async fn sync_profile(app: AppHandle, _state: State<'_, AppState>) -> Result<EnrollmentResult, String> {
|
||||
let session_state = sync_current_session(&app).await?;
|
||||
refresh_tray_menu(&app);
|
||||
Ok(session_state.enrollment)
|
||||
@@ -666,11 +666,9 @@ pub fn run() {
|
||||
refresh_tray_menu(app.handle());
|
||||
|
||||
let app_handle = app.handle().clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
loop {
|
||||
std::thread::spawn(move || loop {
|
||||
refresh_tray_menu(&app_handle);
|
||||
tauri::async_runtime::sleep(std::time::Duration::from_secs(5)).await;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user