feat(ui): starter models filter matches spandrel models to "upscale" search term

This commit is contained in:
psychedelicious 2024-07-23 14:16:25 +10:00
parent d7e0ec52ff
commit 4352341a00

View File

@ -19,12 +19,11 @@ export const StarterModelsResults = ({ results }: StarterModelsResultsProps) =>
const filteredResults = useMemo(() => { const filteredResults = useMemo(() => {
return results.filter((result) => { return results.filter((result) => {
const trimmedSearchTerm = searchTerm.trim().toLowerCase(); const trimmedSearchTerm = searchTerm.trim().toLowerCase();
const name = result.name.toLowerCase(); const matchStrings = [result.name.toLowerCase(), result.type.toLowerCase(), result.description.toLowerCase()];
const type = result.type.toLowerCase(); if (result.type === 'spandrel_image_to_image') {
const description = result.description.toLowerCase(); matchStrings.push('upscale');
return ( }
name.includes(trimmedSearchTerm) || type.includes(trimmedSearchTerm) || description.includes(trimmedSearchTerm) return matchStrings.some((matchString) => matchString.includes(trimmedSearchTerm));
);
}); });
}, [results, searchTerm]); }, [results, searchTerm]);