fix: make search use v3 everywhere (#6840)

This commit is contained in:
Calum H.
2026-07-23 22:16:23 +00:00
committed by GitHub
parent 5c697f675c
commit 0512e0b62b
17 changed files with 241 additions and 149 deletions
@@ -66,6 +66,33 @@ const messages = defineMessages({
defaultMessage: 'No results found for your query!',
},
})
function getLoaderFieldValues(
result: Labrinth.Search.v3.ResultSearchProject,
field: string,
): string[] {
return (result.project_loader_fields?.[field] ?? []).filter(
(value): value is string => typeof value === 'string',
)
}
function getProjectCardTags(result: Labrinth.Search.v3.ResultSearchProject, displayOnly: boolean) {
const tags = new Set(displayOnly ? result.display_categories : result.categories)
for (const loader of result.loaders) {
if (loader !== 'mrpack') {
tags.add(loader)
}
}
if (result.loaders.includes('mrpack')) {
for (const loader of getLoaderFieldValues(result, 'mrpack_loaders')) {
tags.add(loader)
}
}
return Array.from(tags)
}
</script>
<template>
@@ -247,8 +274,8 @@ const messages = defineMessages({
v-for="result in ctx.projectHits.value"
:key="result.project_id"
:link="ctx.getProjectLink(result)"
:title="result.title"
:icon-url="result.icon_url"
:title="result.name"
:icon-url="result.icon_url ?? undefined"
:author="{
name: result.organization == null ? result.author : result.organization,
link:
@@ -266,9 +293,9 @@ const messages = defineMessages({
ctx.effectiveCurrentSortType.value.name === 'newest' ? 'published' : 'updated'
"
:downloads="result.downloads"
:summary="result.description"
:tags="result.display_categories"
:all-tags="result.categories"
:summary="result.summary"
:tags="getProjectCardTags(result, true)"
:all-tags="getProjectCardTags(result, false)"
:deprioritized-tags="ctx.deprioritizedTags.value"
:exclude-loaders="ctx.excludeLoaders.value"
:followers="result.follows"
@@ -276,10 +303,7 @@ const messages = defineMessages({
:color="result.color ?? undefined"
:environment="
['mod', 'modpack'].includes(ctx.projectType.value)
? {
clientSide: result.client_side as Labrinth.Projects.v2.Environment,
serverSide: result.server_side as Labrinth.Projects.v2.Environment,
}
? result.project_loader_fields?.environment?.[0]
: undefined
"
:layout="ctx.effectiveLayout.value"
@@ -46,7 +46,7 @@ export interface BrowseManagerContext {
clearSearch: () => void
onFilterChange: () => void
getProjectLink: (result: Labrinth.Search.v2.ResultSearchProject) => string | RouteLocationRaw
getProjectLink: (result: Labrinth.Search.v3.ResultSearchProject) => string | RouteLocationRaw
getServerProjectLink: (
result: Labrinth.Search.v3.ResultSearchProject,
) => string | RouteLocationRaw
@@ -57,7 +57,7 @@ export interface BrowseManagerContext {
variant: 'app' | 'web'
getCardActions?: (
result: Labrinth.Search.v2.ResultSearchProject | Labrinth.Search.v3.ResultSearchProject,
result: Labrinth.Search.v3.ResultSearchProject,
projectType: string,
) => CardAction[]
@@ -85,13 +85,10 @@ export interface BrowseManagerContext {
result: Labrinth.Search.v3.ResultSearchProject,
) => ServerModpackContent | undefined
onProjectHover?: (result: Labrinth.Search.v2.ResultSearchProject) => void
onProjectHover?: (result: Labrinth.Search.v3.ResultSearchProject) => void
onServerProjectHover?: (result: Labrinth.Search.v3.ResultSearchProject) => void
onProjectHoverEnd?: () => void
onContextMenu?: (
event: MouseEvent,
result: Labrinth.Search.v2.ResultSearchProject | Labrinth.Search.v3.ResultSearchProject,
) => void
onContextMenu?: (event: MouseEvent, result: Labrinth.Search.v3.ResultSearchProject) => void
offline?: Ref<boolean>
filtersMenuOpen?: Ref<boolean>
@@ -3,7 +3,7 @@ import type { Component } from 'vue'
import type { RouteLocationRaw } from 'vue-router'
export interface BrowseSearchResponse {
projectHits: (Labrinth.Search.v2.ResultSearchProject & {
projectHits: (Labrinth.Search.v3.ResultSearchProject & {
installed?: boolean
installing?: boolean
})[]