mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
22 lines
933 B
TypeScript
22 lines
933 B
TypeScript
import { prettifyPlatformCategory } from "@/components/Platforms/platformListColumns";
|
|
import type { Platform } from "@/stores/platforms";
|
|
|
|
/** Every string a platform search matches. Category adds both the stored
|
|
* value ("portable_console") and the label the UI shows ("Portable console"). */
|
|
export function platformSearchTerms(p: Platform): string[] {
|
|
const terms = [p.display_name, p.slug, p.fs_slug];
|
|
if (p.name) terms.push(p.name);
|
|
if (p.category) terms.push(p.category, prettifyPlatformCategory(p.category));
|
|
if (p.family_name) terms.push(p.family_name);
|
|
if (p.abbreviation) terms.push(p.abbreviation);
|
|
terms.push(...p.alternative_names);
|
|
return terms;
|
|
}
|
|
|
|
/** Whether any search term contains `query`, which the caller has lowercased. */
|
|
export function platformMatchesSearch(p: Platform, query: string): boolean {
|
|
return platformSearchTerms(p).some((term) =>
|
|
term.toLowerCase().includes(query),
|
|
);
|
|
}
|