mirror of
https://github.com/modrinth/code.git
synced 2026-08-28 02:24:56 +00:00
fix saving hooks + env vars (#7176)
This commit is contained in:
@@ -11,7 +11,7 @@ import { computed, ref, watch } from 'vue'
|
||||
import { edit } from '@/helpers/instance'
|
||||
import { get } from '@/helpers/settings.ts'
|
||||
|
||||
import type { AppSettings, Hooks } from '../../../../helpers/types'
|
||||
import type { AppSettings } from '../../../../helpers/types'
|
||||
import { injectInstanceSettings } from './instance-settings-context'
|
||||
|
||||
const { handleError } = injectNotificationManager()
|
||||
@@ -26,23 +26,31 @@ const overrideHooks = ref(
|
||||
!!instance.value.hooks.wrapper ||
|
||||
!!instance.value.hooks.post_exit,
|
||||
)
|
||||
const hooks = ref(instance.value.hooks ?? globalSettings.hooks)
|
||||
|
||||
const editInstanceObject = computed(() => {
|
||||
const editInstancePatch: {
|
||||
hooks?: Hooks
|
||||
} = {}
|
||||
|
||||
// When hooks are not overridden per-instance, we want to clear them
|
||||
editInstancePatch.hooks = overrideHooks.value ? hooks.value : {}
|
||||
|
||||
return editInstancePatch
|
||||
const hooksRaw = instance.value.hooks ?? globalSettings.hooks
|
||||
const hooks = ref({
|
||||
pre_launch: hooksRaw.pre_launch ?? '',
|
||||
wrapper: hooksRaw.wrapper ?? '',
|
||||
post_exit: hooksRaw.post_exit ?? '',
|
||||
})
|
||||
|
||||
const editInstanceObject = computed(() => ({
|
||||
hooks: overrideHooks.value
|
||||
? {
|
||||
pre_launch: hooks.value.pre_launch ?? '',
|
||||
wrapper: hooks.value.wrapper ?? '',
|
||||
post_exit: hooks.value.post_exit ?? '',
|
||||
}
|
||||
: {
|
||||
pre_launch: '',
|
||||
wrapper: '',
|
||||
post_exit: '',
|
||||
},
|
||||
}))
|
||||
|
||||
watch(
|
||||
[overrideHooks, hooks],
|
||||
async () => {
|
||||
await edit(instance.value.id, editInstanceObject.value)
|
||||
await edit(instance.value.id, editInstanceObject.value).catch(handleError)
|
||||
},
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user