4242 </label >
4343 <ButtonStyled >
4444 <button
45- :disabled =" invocation === startupSettings?.original_invocation "
45+ :disabled =" invocation === originalInvocation "
4646 class =" !w-full sm:!w-auto"
4747 @click =" resetToDefault"
4848 >
@@ -120,8 +120,9 @@ const props = defineProps<{
120120 server: ModrinthServer ;
121121}>();
122122
123+ await props .server .startup .fetch ();
124+
123125const data = computed (() => props .server .general );
124- const startupSettings = computed (() => props .server .startup );
125126const showAllVersions = ref (false );
126127
127128const jdkVersionMap = [
@@ -137,33 +138,15 @@ const jdkBuildMap = [
137138 { value: " graal" , label: " GraalVM" },
138139];
139140
140- const invocation = ref (" " );
141- const jdkVersion = ref (" " );
142- const jdkBuild = ref (" " );
143-
144- const originalInvocation = ref (" " );
145- const originalJdkVersion = ref (" " );
146- const originalJdkBuild = ref (" " );
147-
148- watch (
149- startupSettings ,
150- (newSettings ) => {
151- if (newSettings ) {
152- invocation .value = newSettings .invocation ;
153- originalInvocation .value = newSettings .invocation ;
154-
155- const jdkVersionLabel =
156- jdkVersionMap .find ((v ) => v .value === newSettings .jdk_version )?.label || " " ;
157- jdkVersion .value = jdkVersionLabel ;
158- originalJdkVersion .value = jdkVersionLabel ;
159-
160- const jdkBuildLabel = jdkBuildMap .find ((v ) => v .value === newSettings .jdk_build )?.label || " " ;
161- jdkBuild .value = jdkBuildLabel ;
162- originalJdkBuild .value = jdkBuildLabel ;
163- }
164- },
165- { immediate: true },
141+ const invocation = ref (props .server .startup .invocation );
142+ const jdkVersion = ref (
143+ jdkVersionMap .find ((v ) => v .value === props .server .startup .jdk_version )?.label ,
166144);
145+ const jdkBuild = ref (jdkBuildMap .find ((v ) => v .value === props .server .startup .jdk_build )?.label );
146+
147+ const originalInvocation = ref (invocation .value );
148+ const originalJdkVersion = ref (jdkVersion .value );
149+ const originalJdkBuild = ref (jdkBuild .value );
167150
168151const hasUnsavedChanges = computed (
169152 () =>
@@ -195,7 +178,7 @@ const displayedJavaVersions = computed(() => {
195178 return showAllVersions .value ? jdkVersionMap .map ((v ) => v .label ) : compatibleJavaVersions .value ;
196179});
197180
198- const saveStartup = async () => {
181+ async function saveStartup() {
199182 try {
200183 isUpdating .value = true ;
201184 const invocationValue = invocation .value ?? " " ;
@@ -232,17 +215,17 @@ const saveStartup = async () => {
232215 } finally {
233216 isUpdating .value = false ;
234217 }
235- };
218+ }
236219
237- const resetStartup = () => {
220+ function resetStartup() {
238221 invocation .value = originalInvocation .value ;
239222 jdkVersion .value = originalJdkVersion .value ;
240223 jdkBuild .value = originalJdkBuild .value ;
241- };
224+ }
242225
243- const resetToDefault = () => {
244- invocation .value = startupSettings .value ?. original_invocation ?? " " ;
245- };
226+ function resetToDefault() {
227+ invocation .value = originalInvocation .value ?? " " ;
228+ }
246229 </script >
247230
248231<style scoped>
0 commit comments