From 6d66aee4ec4d4c88f9918f01b7575d0ffe682712 Mon Sep 17 00:00:00 2001 From: "Calum H." Date: Mon, 6 Jul 2026 17:59:49 +0100 Subject: [PATCH] fix: properly select correct databack versions (#6634) --- apps/app-frontend/src/pages/Browse.vue | 1 - .../browse-tab/composables/install-logic.ts | 19 +++++++++---------- .../ui/src/utils/version-compatibility.ts | 8 ++++++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/app-frontend/src/pages/Browse.vue b/apps/app-frontend/src/pages/Browse.vue index 73cd969063..5a02136b45 100644 --- a/apps/app-frontend/src/pages/Browse.vue +++ b/apps/app-frontend/src/pages/Browse.vue @@ -680,7 +680,6 @@ async function chooseInstanceInstallVersion( const selectedVersion = getLatestMatchingInstallVersion( await getInstallProjectVersions(project.project_id), selectedPreferences, - projectTypeValue, ) if (!selectedVersion) { diff --git a/packages/ui/src/layouts/shared/browse-tab/composables/install-logic.ts b/packages/ui/src/layouts/shared/browse-tab/composables/install-logic.ts index 8a2a52b344..b7e2d7410e 100644 --- a/packages/ui/src/layouts/shared/browse-tab/composables/install-logic.ts +++ b/packages/ui/src/layouts/shared/browse-tab/composables/install-logic.ts @@ -384,6 +384,7 @@ export function getLoaderFilterTypes(contentType: string) { if (contentType === 'plugin') return ['plugin_loader', 'plugin_platform'] if (contentType === 'modpack') return ['modpack_loader'] if (contentType === 'shader') return ['shader_loader'] + if (contentType === 'datapack') return ['datapack_loader'] return [] } @@ -454,7 +455,12 @@ export function getTargetInstallPreferences( return normalizeInstallPreferences({ gameVersions: gameVersion && shouldUseTargetRuntime ? [gameVersion] : undefined, - loaders: loader && shouldUseTargetRuntime ? [loader] : undefined, + loaders: + contentType === 'datapack' + ? ['datapack'] + : loader && shouldUseTargetRuntime + ? [loader] + : undefined, }) } @@ -515,10 +521,9 @@ export function mergeInstallPreferences( export function getLatestMatchingInstallVersion( versions: readonly Labrinth.Versions.v2.Version[], preferences: BrowseInstallPreferences, - contentType: string, ) { return [...versions] - .filter((version) => versionMatchesPreferences(version, preferences, contentType)) + .filter((version) => versionMatchesPreferences(version, preferences)) .sort((a, b) => new Date(b.date_published).getTime() - new Date(a.date_published).getTime())[0] } @@ -543,11 +548,7 @@ export async function resolveInstallPlan( let lastError: Error | null = null for (const candidate of candidates) { - const version = getLatestMatchingInstallVersion( - versions, - candidate.preferences, - options.contentType, - ) + const version = getLatestMatchingInstallVersion(versions, candidate.preferences) if (version) { const fileName = @@ -747,13 +748,11 @@ function hasPreferences(preferences: BrowseInstallPreferences) { function versionMatchesPreferences( version: Labrinth.Versions.v2.Version, preferences: BrowseInstallPreferences, - contentType: string, ) { const gameVersionMatches = !preferences.gameVersions?.length || version.game_versions.some((gameVersion) => preferences.gameVersions?.includes(gameVersion)) if (!gameVersionMatches) return false - if (contentType === 'datapack') return true if (!preferences.loaders?.length) return true const compatibleLoaders = getCompatibleLoaderAliasSet(preferences.loaders) diff --git a/packages/ui/src/utils/version-compatibility.ts b/packages/ui/src/utils/version-compatibility.ts index a2c255bbbc..5006dfe191 100644 --- a/packages/ui/src/utils/version-compatibility.ts +++ b/packages/ui/src/utils/version-compatibility.ts @@ -47,12 +47,16 @@ export function versionMatchesCompatibilityTarget( return false } + const normalizedVersionLoaders = version.loaders.map(normalizeLoaderAlias) + + if (target.projectType === 'datapack') { + return normalizedVersionLoaders.includes('datapack') + } + if (target.projectType && NON_MOD_PROJECT_TYPES.has(target.projectType)) { return true } - const normalizedVersionLoaders = version.loaders.map(normalizeLoaderAlias) - if ( target.projectType === 'modpack' && (normalizedVersionLoaders.length === 0 ||