Pre-existing format drift in seven web/src files (blank-line and indent normalization by vp fmt) plus templ generate normalization across the generated _templ.go files; both swept up while committing the filter-builder fix. No behavior changes.
28 lines
627 B
TypeScript
28 lines
627 B
TypeScript
import { authHeaders } from "./storage";
|
|
|
|
export interface TagSuggestion {
|
|
value: string;
|
|
count: number;
|
|
}
|
|
|
|
export async function searchTagSuggestions(
|
|
query: string,
|
|
libraryId: string,
|
|
): Promise<TagSuggestion[]> {
|
|
if (!query || query.length < 2 || !libraryId) return [];
|
|
|
|
try {
|
|
const response = await fetch(
|
|
`/api/media-items/search?tags=${encodeURIComponent(query)}&library_id=${libraryId}&limit=20`,
|
|
{ headers: authHeaders() },
|
|
);
|
|
|
|
if (!response.ok) return [];
|
|
|
|
const data = await response.json();
|
|
return (data.results || []) as TagSuggestion[];
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|