From 94f74b68c8c79411b00dcc8851b348e9a8176624 Mon Sep 17 00:00:00 2001 From: tdgao Date: Tue, 14 Jul 2026 11:51:26 -0700 Subject: [PATCH] feat: add modpack "includes content" filter and update depends on --- .../components/project/ProjectCombobox.vue | 15 +- .../search/SearchDependsOnFilter.vue | 310 ++++++++++++++++++ .../components/search/SearchSidebarFilter.vue | 97 +----- .../src/layouts/shared/browse-tab/sidebar.vue | 5 + packages/ui/src/locales/en-US/index.json | 39 +++ packages/ui/src/utils/search.ts | 43 +-- 6 files changed, 405 insertions(+), 104 deletions(-) create mode 100644 packages/ui/src/components/search/SearchDependsOnFilter.vue diff --git a/packages/ui/src/components/project/ProjectCombobox.vue b/packages/ui/src/components/project/ProjectCombobox.vue index 15cc1a9b73..fca01c813f 100644 --- a/packages/ui/src/components/project/ProjectCombobox.vue +++ b/packages/ui/src/components/project/ProjectCombobox.vue @@ -84,6 +84,10 @@ const searchResultsCache = ref>(new Map()) const { labrinth } = injectModrinthClient() +function isAllowedProjectType(projectType: string): boolean { + return !props.projectTypes || props.projectTypes.includes(projectType as ProjectType) +} + const userProjectHits = ref([]) const userProjectsFuse = ref | null>(null) @@ -164,7 +168,7 @@ watch( } else { try { const project = await labrinth.projects_v2.get(newId) - if (project) { + if (project && isAllowedProjectType(project.project_type)) { hit = { project_id: project.id, title: project.title, @@ -179,6 +183,9 @@ watch( return } } + if (hit && !isAllowedProjectType(hit.project_type)) { + hit = null + } selectedProject.value = hit if (hit && !options.value.some((o) => o.value === hit!.project_id)) { @@ -221,7 +228,11 @@ const search = async (query: string) => { const uniqueHits: SearchHit[] = [] for (const hit of allHits) { - if (!seenIds.has(hit.project_id) && !excludeSet.has(hit.project_id)) { + if ( + isAllowedProjectType(hit.project_type) && + !seenIds.has(hit.project_id) && + !excludeSet.has(hit.project_id) + ) { seenIds.add(hit.project_id) uniqueHits.push(hit) searchResultsCache.value.set(hit.project_id, hit) diff --git a/packages/ui/src/components/search/SearchDependsOnFilter.vue b/packages/ui/src/components/search/SearchDependsOnFilter.vue new file mode 100644 index 0000000000..e0db00726a --- /dev/null +++ b/packages/ui/src/components/search/SearchDependsOnFilter.vue @@ -0,0 +1,310 @@ + + + diff --git a/packages/ui/src/components/search/SearchSidebarFilter.vue b/packages/ui/src/components/search/SearchSidebarFilter.vue index 1e1b3b1863..4b027d9535 100644 --- a/packages/ui/src/components/search/SearchSidebarFilter.vue +++ b/packages/ui/src/components/search/SearchSidebarFilter.vue @@ -71,48 +71,14 @@