Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions apps/app-frontend/src/composables/useJavaTest.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ref } from 'vue'

import { trackEvent } from '@/helpers/analytics'
import { test_jre } from '@/helpers/jre.js'
import { get_jre, test_jre } from '@/helpers/jre.js'

export default function useJavaTest() {
const testingJava = ref(false)
const javaTestResult = ref<boolean | null>(null)
let testDebounceTimer: ReturnType<typeof setTimeout> | null = null

async function runJavaTest(path: string, version: number, track = true) {
async function runJavaTest(path: string, version: number | null, track = true) {
if (testDebounceTimer) {
clearTimeout(testDebounceTimer)
testDebounceTimer = null
Expand All @@ -19,7 +19,8 @@ export default function useJavaTest() {
}
testingJava.value = true
try {
javaTestResult.value = await test_jre(path, version)
javaTestResult.value =
version === null ? !!(await get_jre(path)) : await test_jre(path, version)
} catch {
javaTestResult.value = false
}
Expand All @@ -30,7 +31,7 @@ export default function useJavaTest() {
}
}

function testJavaInstallationDebounced(path: string, version: number, delay = 600) {
function testJavaInstallationDebounced(path: string, version: number | null, delay = 600) {
if (testDebounceTimer) clearTimeout(testDebounceTimer)
if (!path) {
javaTestResult.value = null
Expand All @@ -39,7 +40,7 @@ export default function useJavaTest() {
testDebounceTimer = setTimeout(() => runJavaTest(path, version, false), delay)
}

async function testJavaInstallation(path: string, version: number, track = false) {
async function testJavaInstallation(path: string, version: number | null, track = false) {
await runJavaTest(path, version, track)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,21 @@ let hasInitialized = false
watch(
javaTestPath,
(newPath) => {
if (newPath && optimalJava?.parsed_version) {
if (newPath) {
if (!hasInitialized) {
testJavaInstallation(newPath, optimalJava?.parsed_version, false)
testJavaInstallation(newPath, null, false)
hasInitialized = true
} else {
testJavaInstallationDebounced(newPath, optimalJava?.parsed_version)
testJavaInstallationDebounced(newPath, null)
}
}
},
{ immediate: true },
)

const javaDetectionModal = ref<{ show: (version: number, current: object) => void } | null>(null)
const javaDetectionModal = ref<{ show: (version: number | null, current: object) => void } | null>(
null,
)

async function handleBrowseJava() {
const result = await open({ multiple: false })
Expand All @@ -84,7 +86,7 @@ async function handleBrowseJava() {
}

function handleDetectJava() {
javaDetectionModal.value?.show(optimalJava?.parsed_version, { path: javaPath.value })
javaDetectionModal.value?.show(null, { path: javaPath.value })
}

const overrideJavaArgs = ref((instance.value.extra_launch_args?.length ?? 0) > 0)
Expand Down Expand Up @@ -262,9 +264,6 @@ const messages = defineMessages({
<CoffeeIcon />
</div>
<div class="flex flex-col gap-2 flex-1 min-w-0">
<span class="font-semibold leading-none mt-2"
>Java {{ optimalJava?.parsed_version }}</span
>
<div class="flex gap-2 items-center">
<Input
:model-value="activePath"
Expand Down Expand Up @@ -306,7 +305,7 @@ const messages = defineMessages({
: undefined,
}"
class="!text-[var(--legacy-button-color,var(--color-base))] [&>svg]:!text-[var(--legacy-button-color,var(--color-primary))]"
@click="testJavaInstallation(activePath, optimalJava?.parsed_version, true)"
@click="testJavaInstallation(activePath, null, true)"
@mouseenter="hoveringTest = true"
@mouseleave="hoveringTest = false"
>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/app-lib/src/install/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub async fn get(
instance_id,
kind AS \"kind!: String\",
status AS \"status!: String\",
state AS \"state!: String\",
json(state) AS \"state!: String\",
created AS \"created!: i64\",
modified AS \"modified!: i64\",
finished,
Expand Down Expand Up @@ -153,7 +153,7 @@ pub async fn list(
instance_id,
kind AS \"kind!: String\",
status AS \"status!: String\",
state AS \"state!: String\",
json(state) AS \"state!: String\",
created AS \"created!: i64\",
modified AS \"modified!: i64\",
finished,
Expand All @@ -174,7 +174,7 @@ pub async fn list(
instance_id,
kind AS \"kind!: String\",
status AS \"status!: String\",
state AS \"state!: String\",
json(state) AS \"state!: String\",
created AS \"created!: i64\",
modified AS \"modified!: i64\",
finished,
Expand Down Expand Up @@ -202,7 +202,7 @@ pub async fn list_interrupted_candidates(
instance_id,
kind AS \"kind!: String\",
status AS \"status!: String\",
state AS \"state!: String\",
json(state) AS \"state!: String\",
created AS \"created!: i64\",
modified AS \"modified!: i64\",
finished,
Expand Down
Loading