feat: misc improvements

This commit is contained in:
2025-03-18 23:27:17 +00:00
parent fe1a32f31b
commit 1191cdd95c
15 changed files with 264 additions and 68 deletions

View File

@ -8,7 +8,7 @@ use crate::pkg::{Package, PkgKey};
use crate::pkg_store::{InstallResult, PackageStore};
use crate::profiles::ongeki::OngekiProfile;
use crate::profiles::{self, AnyProfile, Profile, ProfileMeta, ProfilePaths};
use crate::appdata::AppData;
use crate::appdata::{AppData, ToggleAction};
use crate::model::misc::StartCheckError;
use crate::util;
@ -103,6 +103,9 @@ pub async fn delete_package(state: State<'_, tokio::sync::Mutex<AppData>>, key:
let mut appd = state.lock().await;
appd.pkgs.delete_package(&key, true)
.await
.map_err(|e| e.to_string())?;
appd.toggle_package(key, ToggleAction::Disable)
.map_err(|e| e.to_string())
}
@ -121,7 +124,7 @@ pub async fn toggle_package(state: State<'_, tokio::sync::Mutex<AppData>>, key:
log::debug!("invoke: toggle_package({}, {})", key, enable);
let mut appd = state.lock().await;
appd.toggle_package(key, enable)
appd.toggle_package(key, if enable { ToggleAction::EnableRecursive } else { ToggleAction::Disable })
.map_err(|e| e.to_string())
}
@ -205,6 +208,7 @@ pub async fn load_profile(state: State<'_, Mutex<AppData>>, game: Game, name: St
let mut appd = state.lock().await;
appd.switch_profile(game, name).map_err(|e| e.to_string())?;
appd.fix();
Ok(())
}
@ -290,14 +294,31 @@ pub async fn get_current_profile(state: State<'_, Mutex<AppData>>) -> Result<Opt
}
#[tauri::command]
pub async fn save_current_profile(state: State<'_, Mutex<AppData>>, profile: AnyProfile) -> Result<(), String> {
pub async fn sync_current_profile(state: State<'_, Mutex<AppData>>, profile: AnyProfile) -> Result<(), String> {
log::debug!("invoke: sync_current_profile");
let mut appd = state.lock().await;
if let Some(p) = &mut appd.profile {
p.sync(profile);
}
Ok(())
}
#[tauri::command]
pub async fn save_current_profile(state: State<'_, Mutex<AppData>>) -> Result<(), String> {
log::debug!("invoke: save_current_profile");
let mut appd = state.lock().await;
profile.save().map_err(|e| e.to_string())?;
appd.profile = Some(profile);
Ok(())
appd.fix();
match &mut appd.profile {
Some(p) => {
p.save().map_err(|e| e.to_string())
},
None => {
Err("no profile to save".to_owned())
}
}
}
#[tauri::command]