refac: dedup tags

This commit is contained in:
Timothy Jaeryang Baek 2025-11-04 23:44:33 -05:00
parent cde4b93fa6
commit 314cac0113

View file

@ -121,7 +121,10 @@
if (selectedTag === '') { if (selectedTag === '') {
return true; return true;
} }
return (item.model?.tags ?? []).map((tag) => tag.name).includes(selectedTag);
return (item.model?.tags ?? [])
.map((tag) => tag.name.toLowerCase())
.includes(selectedTag.toLowerCase());
}) })
.filter((item) => { .filter((item) => {
if (selectedConnectionType === '') { if (selectedConnectionType === '') {
@ -139,7 +142,9 @@
if (selectedTag === '') { if (selectedTag === '') {
return true; return true;
} }
return (item.model?.tags ?? []).map((tag) => tag.name).includes(selectedTag); return (item.model?.tags ?? [])
.map((tag) => tag.name.toLowerCase())
.includes(selectedTag.toLowerCase());
}) })
.filter((item) => { .filter((item) => {
if (selectedConnectionType === '') { if (selectedConnectionType === '') {
@ -315,7 +320,7 @@
tags = items tags = items
.filter((item) => !(item.model?.info?.meta?.hidden ?? false)) .filter((item) => !(item.model?.info?.meta?.hidden ?? false))
.flatMap((item) => item.model?.tags ?? []) .flatMap((item) => item.model?.tags ?? [])
.map((tag) => tag.name); .map((tag) => tag.name.toLowerCase());
// Remove duplicates and sort // Remove duplicates and sort
tags = Array.from(new Set(tags)).sort((a, b) => a.localeCompare(b)); tags = Array.from(new Set(tags)).sort((a, b) => a.localeCompare(b));
} }