You've already forked AstralRinth
forked from didirus/AstralRinth
Install mod update dependencies automatically (#4800)
* Redownload version dependencies when updating a mod * Fix update all button as well
This commit is contained in:
@@ -301,11 +301,13 @@ import {
|
|||||||
get_organization_many,
|
get_organization_many,
|
||||||
get_project_many,
|
get_project_many,
|
||||||
get_team_many,
|
get_team_many,
|
||||||
|
get_version,
|
||||||
get_version_many,
|
get_version_many,
|
||||||
} from '@/helpers/cache.js'
|
} from '@/helpers/cache.js'
|
||||||
import { profile_listener } from '@/helpers/events.js'
|
import { profile_listener } from '@/helpers/events.js'
|
||||||
import {
|
import {
|
||||||
add_project_from_path,
|
add_project_from_path,
|
||||||
|
get,
|
||||||
get_projects,
|
get_projects,
|
||||||
remove_project,
|
remove_project,
|
||||||
toggle_disable_project,
|
toggle_disable_project,
|
||||||
@@ -314,6 +316,7 @@ import {
|
|||||||
} from '@/helpers/profile.js'
|
} from '@/helpers/profile.js'
|
||||||
import type { CacheBehaviour, ContentFile, GameInstance } from '@/helpers/types'
|
import type { CacheBehaviour, ContentFile, GameInstance } from '@/helpers/types'
|
||||||
import { highlightModInProfile } from '@/helpers/utils.js'
|
import { highlightModInProfile } from '@/helpers/utils.js'
|
||||||
|
import { installVersionDependencies } from '@/store/install'
|
||||||
|
|
||||||
const { handleError } = injectNotificationManager()
|
const { handleError } = injectNotificationManager()
|
||||||
|
|
||||||
@@ -627,10 +630,15 @@ const sortProjects = (filter: string) => {
|
|||||||
|
|
||||||
const updateAll = async () => {
|
const updateAll = async () => {
|
||||||
const setProjects = []
|
const setProjects = []
|
||||||
|
const outdatedProjects = []
|
||||||
|
|
||||||
for (const [i, project] of projects.value.entries()) {
|
for (const [i, project] of projects.value.entries()) {
|
||||||
if (project.outdated) {
|
if (project.outdated) {
|
||||||
project.updating = true
|
project.updating = true
|
||||||
setProjects.push(i)
|
setProjects.push(i)
|
||||||
|
if (project.updateVersion) {
|
||||||
|
outdatedProjects.push(project.updateVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,6 +654,21 @@ const updateAll = async () => {
|
|||||||
projects.value[index].updateVersion = undefined
|
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) {
|
for (const project of setProjects) {
|
||||||
projects.value[project].updating = false
|
projects.value[project].updating = false
|
||||||
}
|
}
|
||||||
@@ -662,6 +685,19 @@ const updateProject = async (mod: ProjectListEntry) => {
|
|||||||
mod.updating = true
|
mod.updating = true
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||||
mod.path = await update_project(props.instance.path, mod.path).catch(handleError)
|
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.updating = false
|
||||||
|
|
||||||
mod.outdated = false
|
mod.outdated = false
|
||||||
|
|||||||
Reference in New Issue
Block a user