fix: dependencies not appearing when open modal second time

This commit is contained in:
tdgao
2026-07-03 14:43:44 -07:00
parent 021f4dd6d4
commit a10f573a4c
2 changed files with 28 additions and 15 deletions
@@ -485,8 +485,8 @@ watch(
watch( watch(
() => props.resetKey, () => props.resetKey,
() => { () => {
userSelectedGameVersion.value = null userSelectedGameVersion.value = props.initialGameVersion
userSelectedPlatform.value = null userSelectedPlatform.value = props.initialPlatform
showAllVersions.value = defaultShowAllVersions() showAllVersions.value = defaultShowAllVersions()
versionFilter.value = '' versionFilter.value = ''
}, },
@@ -1,14 +1,16 @@
<template> <template>
<NewModal ref="modal" :on-show="onShow" :on-hide="onHide" width="544px"> <NewModal ref="modal" :on-show="onShow" :on-hide="onHide" width="544px">
<template v-if="project" #title> <template #title>
<Avatar :src="project.icon_url" :alt="project.title" class="icon" size="32px" /> <template v-if="project">
<div <Avatar :src="project.icon_url" :alt="project.title" class="icon" size="32px" />
ref="downloadTitleRef" <div
v-tooltip="truncatedTooltip(downloadTitleRef, downloadTitle)" ref="downloadTitleRef"
class="truncate text-lg font-extrabold text-contrast" v-tooltip="truncatedTooltip(downloadTitleRef, downloadTitle)"
> class="truncate text-lg font-extrabold text-contrast"
{{ downloadTitle }} >
</div> {{ downloadTitle }}
</div>
</template>
</template> </template>
<template #default> <template #default>
<div v-if="project" class="mx-auto flex w-full flex-col gap-4"> <div v-if="project" class="mx-auto flex w-full flex-col gap-4">
@@ -336,7 +338,8 @@ async function show(
options: ProjectDownloadModalShowOptions = {}, options: ProjectDownloadModalShowOptions = {},
): Promise<void> { ): Promise<void> {
if (!modal.value || modalOpen.value) return if (!modal.value || modalOpen.value) return
clearCloseStateResetTimeout() await waitForCloseStateReset()
if (!modal.value || modalOpen.value) return
showOptions.value = { showOptions.value = {
...getDefaultShowOptions(), ...getDefaultShowOptions(),
...options, ...options,
@@ -344,15 +347,14 @@ async function show(
showProjectId.value = showOptions.value.projectId ?? null showProjectId.value = showOptions.value.projectId ?? null
await nextTick() await nextTick()
if (!(await loadProjectForModal(!!showOptions.value.projectId))) return if (!(await loadProjectForModal(!!showOptions.value.projectId))) return
resetDownloadState()
modalOpen.value = true modalOpen.value = true
modal.value.show(event) modal.value.show(event)
} }
async function hide() { function hide() {
if (!modal.value || !modalOpen.value) return if (!modal.value || !modalOpen.value) return
modal.value?.hide() modal.value?.hide()
await nextTick()
downloadProjectResetKey.value += 1
} }
function onDownload() { function onDownload() {
@@ -382,6 +384,11 @@ function clearCloseStateResetTimeout() {
closeStateResetTimeout = null closeStateResetTimeout = null
} }
async function waitForCloseStateReset() {
if (!closeStateResetTimeout) return
await new Promise((resolve) => setTimeout(resolve, MODAL_CLOSE_STATE_RESET_MS))
}
async function loadProjectForModal(forceRefetch: boolean) { async function loadProjectForModal(forceRefetch: boolean) {
if (!routeProjectId.value) return false if (!routeProjectId.value) return false
if (!forceRefetch && projectRaw.value) return true if (!forceRefetch && projectRaw.value) return true
@@ -390,6 +397,12 @@ async function loadProjectForModal(forceRefetch: boolean) {
return !!data return !!data
} }
function resetDownloadState() {
projectDownloadSelection.value = getDefaultProjectDownloadSelection()
dependencyDownloadFiles.value = []
downloadProjectResetKey.value += 1
}
function openFromHash() { function openFromHash() {
if ( if (
!props.useRouteHash || !props.useRouteHash ||