fix: app states

This commit is contained in:
DecDuck
2025-07-26 17:57:12 +10:00
parent f92ec38231
commit aad2d964eb
7 changed files with 53 additions and 43 deletions
+4 -3
View File
@@ -1,10 +1,11 @@
use log::{debug, error};
use tauri::AppHandle;
use tokio::sync::Mutex;
use crate::AppState;
#[tauri::command]
pub async fn quit(app: tauri::AppHandle, state: tauri::State<'_, std::sync::Mutex<AppState<'_>>>) -> Result<(), ()> {
pub async fn quit(app: tauri::AppHandle, state: tauri::State<'_, Mutex<AppState<'_>>>) -> Result<(), ()> {
cleanup_and_exit(&app, &state).await;
Ok(())
@@ -12,10 +13,10 @@ pub async fn quit(app: tauri::AppHandle, state: tauri::State<'_, std::sync::Mute
pub async fn cleanup_and_exit(
app: &AppHandle,
state: &tauri::State<'_, std::sync::Mutex<AppState<'_>>>,
state: &tauri::State<'_, Mutex<AppState<'_>>>,
) {
debug!("cleaning up and exiting application");
let download_manager = state.lock().unwrap().download_manager.clone();
let download_manager = state.lock().await.download_manager.clone();
match download_manager.ensure_terminated().await {
Ok(res) => match res {
Ok(_) => debug!("download manager terminated correctly"),