Install mod update dependencies automatically (#4800)

* Redownload version dependencies when updating a mod

* Fix update all button as well
This commit is contained in:
aecsocket
2025-11-24 13:35:14 +00:00
committed by GitHub
parent 31417a2aa1
commit 0178fddc38

View File

@@ -301,11 +301,13 @@ import {
get_organization_many,
get_project_many,
get_team_many,
get_version,
get_version_many,
} from '@/helpers/cache.js'
import { profile_listener } from '@/helpers/events.js'
import {
add_project_from_path,
get,
get_projects,
remove_project,
toggle_disable_project,
@@ -314,6 +316,7 @@ import {
} from '@/helpers/profile.js'
import type { CacheBehaviour, ContentFile, GameInstance } from '@/helpers/types'
import { highlightModInProfile } from '@/helpers/utils.js'
import { installVersionDependencies } from '@/store/install'
const { handleError } = injectNotificationManager()
@@ -627,10 +630,15 @@ const sortProjects = (filter: string) => {
const updateAll = async () => {
const setProjects = []
const outdatedProjects = []
for (const [i, project] of projects.value.entries()) {
if (project.outdated) {
project.updating = true
setProjects.push(i)
if (project.updateVersion) {
outdatedProjects.push(project.updateVersion)
}
}
}
@@ -646,6 +654,21 @@ const updateAll = async () => {
projects.value[index].updateVersion = undefined
}
}
if (outdatedProjects.length > 0) {
const profile = await get(props.instance.path).catch(handleError)
if (profile) {
for (const versionId of outdatedProjects) {
const versionData = await get_version(versionId, 'must_revalidate').catch(handleError)
if (versionData) {
await installVersionDependencies(profile, versionData).catch(handleError)
}
}
}
}
for (const project of setProjects) {
projects.value[project].updating = false
}
@@ -662,6 +685,19 @@ const updateProject = async (mod: ProjectListEntry) => {
mod.updating = true
await new Promise((resolve) => setTimeout(resolve, 0))
mod.path = await update_project(props.instance.path, mod.path).catch(handleError)
if (mod.updateVersion) {
const versionData = await get_version(mod.updateVersion, 'must_revalidate').catch(handleError)
if (versionData) {
const profile = await get(props.instance.path).catch(handleError)
if (profile) {
await installVersionDependencies(profile, versionData).catch(handleError)
}
}
}
mod.updating = false
mod.outdated = false