chore: Fix weird java prefix + add force reinstall button
This commit is contained in:
parent
74a0e27dbc
commit
cedc33bef0
7 changed files with 65 additions and 14 deletions
|
|
@ -199,7 +199,19 @@ pub async fn get_worlds(uuid: Uuid) -> Result<Vec<String>, String> {
|
|||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_optimal_java_version(cluster_id: Uuid) -> Result<JavaVersion, String> {
|
||||
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<JavaVersion, String> {
|
||||
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(())
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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={<Trash01Icon />}
|
||||
title="Delete Cluster"
|
||||
/>
|
||||
<SettingsRow
|
||||
children={(
|
||||
<Button
|
||||
buttonStyle="secondary"
|
||||
children="Repair"
|
||||
iconLeft={<Tool02Icon />}
|
||||
onClick={repairCluster}
|
||||
/>
|
||||
)}
|
||||
description="Verifies whether all assets, libraries and natives were properly installed."
|
||||
icon={<Tool02Icon />}
|
||||
title="Verify Cluster"
|
||||
/>
|
||||
</ScrollableContainer>
|
||||
</Sidebar.Page>
|
||||
);
|
||||
|
|
@ -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) {
|
|||
<Button
|
||||
buttonStyle="iconSecondary"
|
||||
children={<Share07Icon />}
|
||||
disabled={props.editMode()}
|
||||
// disabled={props.editMode()}
|
||||
disabled={true}
|
||||
/>
|
||||
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ function ClusterJavaVersionModal(props: ModalProps & {
|
|||
}) {
|
||||
const [_, modalProps] = splitProps(props, ['javaVersion', 'javaVersions']);
|
||||
|
||||
const javaVersions = createMemo(() => Object.entries(props.javaVersions).sort((a, b) => Number.parseFloat(b[1].version) - Number.parseFloat(a[1].version)));
|
||||
const javaVersions = createMemo(() => Object.entries(props.javaVersions.get()).sort((a, b) => Number.parseFloat(b[1].version) - Number.parseFloat(a[1].version)));
|
||||
const [selected, setSelected] = createSignal<number>(0);
|
||||
|
||||
onMount(async () => {
|
||||
|
|
@ -490,7 +490,7 @@ function ClusterJavaVersionModal(props: ModalProps & {
|
|||
props.javaVersion.set(pkg);
|
||||
props.javaVersions.set({
|
||||
...props.javaVersions?.get(),
|
||||
[`JAVA_${version}`]: pkg,
|
||||
[version]: pkg,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -522,6 +522,7 @@ function ClusterJavaVersionModal(props: ModalProps & {
|
|||
<Dropdown.Row>
|
||||
<span class="capitalize">
|
||||
Java
|
||||
{' '}
|
||||
{major}
|
||||
</span>
|
||||
</Dropdown.Row>
|
||||
|
|
@ -542,7 +543,7 @@ function GlobalJavaVersionModal(props: ModalProps & {
|
|||
const setPackage = (pkg: JavaVersion, version: string) => {
|
||||
props.javaVersions?.set({
|
||||
...props.javaVersions?.get(),
|
||||
[`JAVA_${version}`]: pkg,
|
||||
[version]: pkg,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -561,6 +562,7 @@ function GlobalJavaVersionModal(props: ModalProps & {
|
|||
<>
|
||||
<span class="capitalize">
|
||||
Java
|
||||
{' '}
|
||||
{major}
|
||||
</span>
|
||||
<TextField
|
||||
|
|
|
|||
14
packages/client/src/bindings.ts
generated
14
packages/client/src/bindings.ts
generated
|
|
@ -204,9 +204,19 @@ export const commands = {
|
|||
else return { status: 'error', error: e as any };
|
||||
}
|
||||
},
|
||||
async getOptimalJavaVersion(clusterId: string): Promise<Result<JavaVersion, string>> {
|
||||
async getOptimalJavaVersion(uuid: string): Promise<Result<JavaVersion, string>> {
|
||||
try {
|
||||
return { status: 'ok', data: await TAURI_INVOKE('get_optimal_java_version', { clusterId }) };
|
||||
return { status: 'ok', data: await TAURI_INVOKE('get_optimal_java_version', { uuid }) };
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error)
|
||||
throw e;
|
||||
else return { status: 'error', error: e as any };
|
||||
}
|
||||
},
|
||||
async repairCluster(uuid: string): Promise<Result<null, string>> {
|
||||
try {
|
||||
return { status: 'ok', data: await TAURI_INVOKE('repair_cluster', { uuid }) };
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::proxy::send::send_cluster;
|
|||
use crate::prelude::{ClusterPath, JavaVersion, PackagePath};
|
||||
use crate::proxy::ClusterPayloadType;
|
||||
pub use crate::store::{Cluster, JavaOptions, State};
|
||||
use crate::store::{MinecraftCredentials, ProcessorChild};
|
||||
use crate::store::{ClusterStage, MinecraftCredentials, ProcessorChild};
|
||||
|
||||
use onelauncher_utils::io::{self, IOError};
|
||||
|
||||
|
|
@ -420,6 +420,15 @@ pub async fn update_playtime(path: &ClusterPath) -> crate::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// This forces the cluster to be verified (and possibly reinstalled).
|
||||
pub async fn repair_cluster(path: &ClusterPath) -> crate::Result<()> {
|
||||
let cluster = get(path)
|
||||
.await?
|
||||
.ok_or_else(|| anyhow::anyhow!("failed to repair cluster at path {}", path))?;
|
||||
|
||||
crate::game::install_minecraft(&cluster, None, true).await
|
||||
}
|
||||
|
||||
/// Sanitize a user-inputted [`Cluster`] name.
|
||||
#[must_use]
|
||||
pub fn sanitize_cluster_name(input: &str) -> String {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ pub async fn install_minecraft(
|
|||
let mut settings = state.settings.write().await;
|
||||
settings
|
||||
.java_versions
|
||||
.insert(format!("JAVA_{key}"), java_version.clone());
|
||||
.insert(key.to_string(), java_version.clone());
|
||||
}
|
||||
State::sync().await?;
|
||||
}
|
||||
|
|
@ -535,7 +535,7 @@ pub async fn java_version_from_cluster(
|
|||
let state = State::get().await?;
|
||||
let settings = state.settings.read().await;
|
||||
|
||||
if let Some(j) = settings.java_versions.get(&format!("JAVA_{key}")) {
|
||||
if let Some(j) = settings.java_versions.get(&key.to_string()) {
|
||||
return Ok(Some(j.clone()));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue