Fix and unify version selection when installing mods and filtering (#4252)

* Fix and unify version selection when installing mods

* Update version list filters to match install version selection logic

* Fix lint issues

---------

Co-authored-by: Cal H. <contact@cal.engineer>
This commit is contained in:
Juhan Oskar Hennoste
2025-08-27 16:47:39 +03:00
committed by GitHub
parent 0925abfd1c
commit a2c07c92f8
3 changed files with 66 additions and 38 deletions

View File

@@ -22,7 +22,11 @@ import {
get,
list,
} from '@/helpers/profile'
import { installVersionDependencies } from '@/store/install.js'
import {
findPreferredVersion,
installVersionDependencies,
isVersionCompatible,
} from '@/store/install.js'
const { handleError } = injectNotificationManager()
const router = useRouter()
@@ -49,14 +53,11 @@ const shownProfiles = computed(() =>
return profile.name.toLowerCase().includes(searchFilter.value.toLowerCase())
})
.filter((profile) => {
const loaders = versions.value.flatMap((v) => v.loaders)
return (
versions.value.flatMap((v) => v.game_versions).includes(profile.game_version) &&
(project.value.project_type === 'mod'
? loaders.includes(profile.loader) || loaders.includes('minecraft')
: true)
)
const version = {
game_versions: versions.value.flatMap((v) => v.game_versions),
loaders: versions.value.flatMap((v) => v.loaders),
}
return isVersionCompatible(version, project.value, profile)
}),
)
@@ -94,14 +95,7 @@ defineExpose({
async function install(instance) {
instance.installing = true
const version = versions.value.find((v) => {
return (
v.game_versions.includes(instance.game_version) &&
(project.value.project_type === 'mod'
? v.loaders.includes(instance.loader) || v.loaders.includes('minecraft')
: true)
)
})
const version = findPreferredVersion(versions.value, project.value, instance)
if (!version) {
instance.installing = false