You've already forked AstralRinth
forked from didirus/AstralRinth
Initial bug fixes (#127)
* Initial bug fixes * fix compile error on non-mac * Fix even more bugs * Fix more * fix more * fix build * fix build * address review comments
This commit is contained in:
@@ -16,6 +16,11 @@ pub async fn auth_authenticate_await_completion() -> Result<Credentials> {
|
||||
Ok(auth::authenticate_await_complete_flow().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn auth_cancel_flow() -> Result<()> {
|
||||
Ok(auth::cancel_flow().await?)
|
||||
}
|
||||
|
||||
/// Refresh some credentials using Hydra, if needed
|
||||
// invoke('auth_refresh',user)
|
||||
#[tauri::command]
|
||||
|
||||
@@ -18,11 +18,7 @@ pub async fn logs_get_logs(
|
||||
profile_uuid: Uuid,
|
||||
clear_contents: Option<bool>,
|
||||
) -> Result<Vec<Logs>> {
|
||||
use std::time::Instant;
|
||||
let now = Instant::now();
|
||||
let val = logs::get_logs(profile_uuid, clear_contents).await?;
|
||||
let elapsed = now.elapsed();
|
||||
println!("Elapsed: {:.2?}", elapsed);
|
||||
|
||||
Ok(val)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ pub mod profile;
|
||||
pub mod profile_create;
|
||||
pub mod settings;
|
||||
pub mod tags;
|
||||
pub mod utils;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@ use theseus::prelude::*;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn pack_install_version_id(
|
||||
project_id: String,
|
||||
version_id: String,
|
||||
pack_title: String,
|
||||
pack_icon: Option<String>,
|
||||
) -> Result<PathBuf> {
|
||||
let res =
|
||||
pack::install_pack_from_version_id(version_id, pack_title, pack_icon)
|
||||
.await?;
|
||||
let res = pack::install_pack_from_version_id(
|
||||
project_id, version_id, pack_title, pack_icon,
|
||||
)
|
||||
.await?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ pub async fn profile_update_project(
|
||||
path: &Path,
|
||||
project_path: &Path,
|
||||
) -> Result<PathBuf> {
|
||||
Ok(profile::update_project(path, project_path).await?)
|
||||
Ok(profile::update_project(path, project_path, None).await?)
|
||||
}
|
||||
|
||||
// Adds a project to a profile from a version ID
|
||||
|
||||
76
theseus_gui/src-tauri/src/api/utils.rs
Normal file
76
theseus_gui/src-tauri/src/api/utils.rs
Normal file
@@ -0,0 +1,76 @@
|
||||
use crate::api::Result;
|
||||
use std::process::Command;
|
||||
|
||||
// cfg only on mac os
|
||||
// disables mouseover and fixes a random crash error only fixed by recent versions of macos
|
||||
#[cfg(target_os = "macos")]
|
||||
#[tauri::command]
|
||||
pub async fn should_disable_mouseover() -> bool {
|
||||
// We try to match version to 12.2 or higher. If unrecognizable to pattern or lower, we default to the css with disabled mouseover for safety
|
||||
let os = os_info::get();
|
||||
if let os_info::Version::Semantic(major, minor, _) = os.version() {
|
||||
if *major >= 12 && *minor >= 3 {
|
||||
// Mac os version is 12.3 or higher, we allow mouseover
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[tauri::command]
|
||||
pub async fn should_disable_mouseover() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn show_in_folder(path: String) -> Result<()> {
|
||||
{
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
Command::new("explorer")
|
||||
.args(["/select,", &path]) // The comma after select is not a typo
|
||||
.spawn()?;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
use std::fs;
|
||||
use std::fs::metadata;
|
||||
use std::path::PathBuf;
|
||||
|
||||
if path.contains(",") {
|
||||
// see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76
|
||||
let new_path = match metadata(&path)?.is_dir() {
|
||||
true => path.clone(),
|
||||
false => {
|
||||
let mut path2 = PathBuf::from(path.clone());
|
||||
path2.pop();
|
||||
path2.to_string_lossy().to_string()
|
||||
}
|
||||
};
|
||||
Command::new("xdg-open").arg(&new_path).spawn()?;
|
||||
} else {
|
||||
Command::new("dbus-send")
|
||||
.args([
|
||||
"--session",
|
||||
"--dest=org.freedesktop.FileManager1",
|
||||
"--type=method_call",
|
||||
"/org/freedesktop/FileManager1",
|
||||
"org.freedesktop.FileManager1.ShowItems",
|
||||
format!("array:string:\"file://{path}\"").as_str(),
|
||||
"string:\"\"",
|
||||
])
|
||||
.spawn()?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
Command::new("open").args(["-R", &path]).spawn()?;
|
||||
}
|
||||
|
||||
Ok::<(), theseus::Error>(())
|
||||
}?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user