Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions apps/app-frontend/src/pages/instance/Mods.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()

Expand Down Expand Up @@ -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)
}
}
}

Expand All @@ -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
}
Expand All @@ -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
Expand Down