From cedc33bef0049273313ffefafe0742d84d6a0f22 Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Sun, 15 Dec 2024 11:41:50 +0100 Subject: [PATCH] chore: Fix weird java prefix + add force reinstall button --- apps/desktop/src/api/commands/cluster.rs | 16 +++++++++++-- apps/desktop/src/api/commands/mod.rs | 2 +- .../src/ui/pages/cluster/ClusterOverview.tsx | 24 ++++++++++++++++--- .../pages/settings/game/SettingsMinecraft.tsx | 8 ++++--- packages/client/src/bindings.ts | 14 +++++++++-- packages/core/src/api/cluster/mod.rs | 11 ++++++++- packages/core/src/game/mod.rs | 4 ++-- 7 files changed, 65 insertions(+), 14 deletions(-) diff --git a/apps/desktop/src/api/commands/cluster.rs b/apps/desktop/src/api/commands/cluster.rs index 432dd254..542679a7 100644 --- a/apps/desktop/src/api/commands/cluster.rs +++ b/apps/desktop/src/api/commands/cluster.rs @@ -199,7 +199,19 @@ pub async fn get_worlds(uuid: Uuid) -> Result, String> { #[specta::specta] #[tauri::command] -pub async fn get_optimal_java_version(cluster_id: Uuid) -> Result { - let cluster_path = cluster::get_by_uuid(cluster_id).await?.ok_or("Cluster not found")?.cluster_path(); +pub async fn get_optimal_java_version(uuid: Uuid) -> Result { + let cluster_path = cluster::get_by_uuid(uuid).await?.ok_or("Cluster not found")?.cluster_path(); Ok(cluster::get_optimal_java_version(&cluster_path).await?.ok_or("No Java version found")?) +} + +#[specta::specta] +#[tauri::command] +pub async fn repair_cluster(uuid: Uuid) -> Result<(), String> { + let cluster = cluster::get_by_uuid(uuid) + .await? + .ok_or("cluster not found")?; + + cluster::repair_cluster(&cluster.cluster_path()).await?; + + Ok(()) } \ No newline at end of file diff --git a/apps/desktop/src/api/commands/mod.rs b/apps/desktop/src/api/commands/mod.rs index b659e31e..3e3d5744 100644 --- a/apps/desktop/src/api/commands/mod.rs +++ b/apps/desktop/src/api/commands/mod.rs @@ -1,6 +1,5 @@ use interpulse::api::minecraft::Version; use onelauncher::data::Settings; -use onelauncher::game::metadata; use onelauncher::settings; use tauri::{AppHandle, Manager}; @@ -44,6 +43,7 @@ macro_rules! collect_commands { get_screenshots, get_worlds, get_optimal_java_version, + repair_cluster, // Processor get_running_clusters, get_processes_by_path, diff --git a/apps/frontend/src/ui/pages/cluster/ClusterOverview.tsx b/apps/frontend/src/ui/pages/cluster/ClusterOverview.tsx index aabb94aa..42af28a9 100644 --- a/apps/frontend/src/ui/pages/cluster/ClusterOverview.tsx +++ b/apps/frontend/src/ui/pages/cluster/ClusterOverview.tsx @@ -2,7 +2,7 @@ import type { Cluster } from '@onelauncher/client/bindings'; import { useNavigate } from '@solidjs/router'; import * as dialog from '@tauri-apps/plugin-dialog'; import { open } from '@tauri-apps/plugin-shell'; -import { Edit02Icon, FolderIcon, ImagePlusIcon, LinkExternal01Icon, PlayIcon, Save01Icon, Share07Icon, Trash01Icon } from '@untitled-theme/icons-solid'; +import { Edit02Icon, FolderIcon, ImagePlusIcon, LinkExternal01Icon, PlayIcon, Save01Icon, Share07Icon, Tool02Icon, Trash01Icon } from '@untitled-theme/icons-solid'; import { bridge } from '~imports'; import TextField from '~ui/components/base/TextField'; import Modal, { createModal, type ModalProps } from '~ui/components/overlay/Modal'; @@ -63,6 +63,10 @@ function ClusterOverview() { navigate('/'); } + async function repairCluster() { + await bridge.commands.repairCluster(cluster()!.uuid); + } + function madeChanges() { const name = untrack(() => newName()); const cover = untrack(() => newCover()); @@ -195,6 +199,19 @@ function ClusterOverview() { icon={} title="Delete Cluster" /> + } + onClick={repairCluster} + /> + )} + description="Verifies whether all assets, libraries and natives were properly installed." + icon={} + title="Verify Cluster" + /> ); @@ -260,7 +277,7 @@ function Banner(props: BannerProps) { if (selected === null) return; - props.setNewCover(selected.path); + props.setNewCover(selected); } function updateName(name: string) { @@ -338,7 +355,8 @@ function Banner(props: BannerProps) {