Skip to content

Commit d5b7ac3

Browse files
authored
fix: setting states not persisting (#4872)
Closes: 4867
1 parent fec395a commit d5b7ac3

File tree

2 files changed

+27
-52
lines changed

2 files changed

+27
-52
lines changed

apps/app-frontend/src/components/ui/instance_settings/JavaSettings.vue

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import useMemorySlider from '@/composables/useMemorySlider'
99
import { edit, get_optimal_jre_key } from '@/helpers/profile'
1010
import { get } from '@/helpers/settings.ts'
1111
12-
import type { AppSettings, InstanceSettingsTabProps, MemorySettings } from '../../../helpers/types'
12+
import type { AppSettings, InstanceSettingsTabProps } from '../../../helpers/types'
1313
1414
const { handleError } = injectNotificationManager()
1515
const { formatMessage } = useVIntl()
@@ -22,12 +22,12 @@ const overrideJavaInstall = ref(!!props.instance.java_path)
2222
const optimalJava = readonly(await get_optimal_jre_key(props.instance.path).catch(handleError))
2323
const javaInstall = ref({ path: optimalJava.path ?? props.instance.java_path })
2424
25-
const overrideJavaArgs = ref(props.instance.extra_launch_args?.length !== undefined)
25+
const overrideJavaArgs = ref((props.instance.extra_launch_args?.length ?? 0) > 0)
2626
const javaArgs = ref(
2727
(props.instance.extra_launch_args ?? globalSettings.extra_launch_args).join(' '),
2828
)
2929
30-
const overrideEnvVars = ref(props.instance.custom_env_vars?.length !== undefined)
30+
const overrideEnvVars = ref((props.instance.custom_env_vars?.length ?? 0) > 0)
3131
const envVars = ref(
3232
(props.instance.custom_env_vars ?? globalSettings.custom_env_vars)
3333
.map((x) => x.join('='))
@@ -42,36 +42,23 @@ const { maxMemory, snapPoints } = (await useMemorySlider().catch(handleError)) a
4242
}
4343
4444
const editProfileObject = computed(() => {
45-
const editProfile: {
46-
java_path?: string
47-
extra_launch_args?: string[]
48-
custom_env_vars?: string[][]
49-
memory?: MemorySettings
50-
} = {}
51-
52-
if (overrideJavaInstall.value) {
53-
if (javaInstall.value.path !== '') {
54-
editProfile.java_path = javaInstall.value.path.replace('java.exe', 'javaw.exe')
55-
}
56-
}
57-
58-
if (overrideJavaArgs.value) {
59-
editProfile.extra_launch_args = javaArgs.value.trim().split(/\s+/).filter(Boolean)
60-
}
61-
62-
if (overrideEnvVars.value) {
63-
editProfile.custom_env_vars = envVars.value
64-
.trim()
65-
.split(/\s+/)
66-
.filter(Boolean)
67-
.map((x) => x.split('=').filter(Boolean))
68-
}
69-
70-
if (overrideMemorySettings.value) {
71-
editProfile.memory = memory.value
45+
return {
46+
java_path:
47+
overrideJavaInstall.value && javaInstall.value.path !== ''
48+
? javaInstall.value.path.replace('java.exe', 'javaw.exe')
49+
: null,
50+
extra_launch_args: overrideJavaArgs.value
51+
? javaArgs.value.trim().split(/\s+/).filter(Boolean)
52+
: null,
53+
custom_env_vars: overrideEnvVars.value
54+
? envVars.value
55+
.trim()
56+
.split(/\s+/)
57+
.filter(Boolean)
58+
.map((x) => x.split('=').filter(Boolean))
59+
: null,
60+
memory: overrideMemorySettings.value ? memory.value : null,
7261
}
73-
74-
return editProfile
7562
})
7663
7764
watch(

apps/app-frontend/src/components/ui/instance_settings/WindowSettings.vue

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@ const fullscreenSetting: Ref<boolean> = ref(
2626
)
2727
2828
const editProfileObject = computed(() => {
29-
const editProfile: {
30-
force_fullscreen?: boolean
31-
game_resolution?: [number, number]
32-
} = {}
33-
34-
if (overrideWindowSettings.value) {
35-
editProfile.force_fullscreen = fullscreenSetting.value
36-
37-
if (!fullscreenSetting.value) {
38-
editProfile.game_resolution = resolution.value
29+
if (!overrideWindowSettings.value) {
30+
return {
31+
force_fullscreen: null,
32+
game_resolution: null,
3933
}
4034
}
41-
42-
return editProfile
35+
return {
36+
force_fullscreen: fullscreenSetting.value,
37+
game_resolution: fullscreenSetting.value ? null : resolution.value,
38+
}
4339
})
4440
4541
watch(
@@ -95,14 +91,6 @@ const messages = defineMessages({
9591
<Checkbox
9692
v-model="overrideWindowSettings"
9793
:label="formatMessage(messages.customWindowSettings)"
98-
@update:model-value="
99-
(value) => {
100-
if (!value) {
101-
resolution = globalSettings.game_resolution
102-
fullscreenSetting = globalSettings.force_fullscreen
103-
}
104-
}
105-
"
10694
/>
10795
<div class="mt-2 flex items-center gap-4 justify-between">
10896
<div>

0 commit comments

Comments
 (0)