fix: MSA Webview works now + Fixed empty "pre" and "wrapper" commands causing errors

This commit is contained in:
LynithDev 2024-08-07 21:30:29 +02:00
parent 4787a571ef
commit f289a5c768
2 changed files with 22 additions and 7 deletions

View file

@ -43,10 +43,6 @@ pub async fn set_default_user(uuid: Uuid) -> Result<(), String> {
#[tauri::command]
pub async fn auth_login(handle: AppHandle) -> Result<Option<MinecraftCredentials>, String> {
let flow = minecraft::begin().await?;
// let result = (*(tokio::spawn(async {
// Box::pin(spawn_webview(handle, flow).await)
// }).await.map_err(|err| err.to_string())?)).clone()?;
let result = spawn_webview(handle, flow).await?;
Ok(result)

View file

@ -131,7 +131,16 @@ pub async fn run_credentials(
.init_hooks
.as_ref()
.unwrap_or(&settings.init_hooks)
.pre;
.pre
.as_ref()
.and_then(|it| {
if it.is_empty() {
None
} else {
Some(it.clone())
}
});
if let Some(hook) = pre {
// TODO: hook parameters
let mut cmd = hook.split(' ');
@ -161,10 +170,20 @@ pub async fn run_credentials(
.as_ref()
.and_then(|it| it.custom_arguments.as_ref())
.unwrap_or(&settings.custom_java_args);
let wrapper = cluster
.init_hooks
.as_ref()
.map_or(&settings.init_hooks.wrapper, |it| &it.wrapper);
.map_or(&settings.init_hooks.wrapper, |it| &it.wrapper)
.as_ref()
.and_then(|it| {
if it.is_empty() {
None
} else {
Some(it.clone())
}
});
let memory = cluster.memory.unwrap_or(settings.memory);
let resolution = cluster.resolution.unwrap_or(settings.resolution);
let env_args = cluster
@ -194,7 +213,7 @@ pub async fn run_credentials(
creds,
&resolution,
&memory,
wrapper,
&wrapper,
)
.await?;