build search global

This commit is contained in:
2026-03-28 02:02:47 -05:00
parent 0e03cec842
commit b1dd8df61e

View File

@@ -49,12 +49,13 @@ export function Gallery() {
setSearchTimer(t); setSearchTimer(t);
} }
const isSearching = !!debouncedSearch;
const { data, isLoading, isError } = useMemes({ const { data, isLoading, isError } = useMemes({
tag: activeTag ?? undefined, tag: activeTag ?? undefined,
q: debouncedSearch || undefined, q: debouncedSearch || undefined,
parent_only: true, parent_only: true,
collection_id: activeCollectionId ?? undefined, collection_id: isSearching ? undefined : (activeCollectionId ?? undefined),
limit, limit: isSearching ? 200 : limit,
}); });
const { data: tags } = useTags(); const { data: tags } = useTags();
@@ -94,7 +95,7 @@ export function Gallery() {
type="text" type="text"
value={search} value={search}
onChange={(e) => handleSearchChange(e.target.value)} onChange={(e) => handleSearchChange(e.target.value)}
placeholder={`Search${activeCollection ? ` in ${activeCollection.name}` : ''}`} placeholder="Search all memes…"
className="w-full bg-zinc-900 border border-zinc-700 rounded-lg pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:border-accent placeholder-zinc-600" className="w-full bg-zinc-900 border border-zinc-700 rounded-lg pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:border-accent placeholder-zinc-600"
/> />
{search && ( {search && (
@@ -206,12 +207,13 @@ export function Gallery() {
: (() => { : (() => {
const count = data?.total ?? 0; const count = data?.total ?? 0;
const showing = data?.memes.length ?? 0; const showing = data?.memes.length ?? 0;
const showing = data?.memes.length ?? 0;
let label = `${count} meme${count !== 1 ? 's' : ''}`; let label = `${count} meme${count !== 1 ? 's' : ''}`;
if (isUnsorted && count > 50 && !debouncedSearch && !activeTag) { if (isUnsorted && count > 50 && !debouncedSearch && !activeTag) {
label = `Showing last 50 of ${count}`; label = `Showing last 50 of ${count}`;
} }
if (activeTag) label += ` tagged "${activeTag}"`; if (activeTag) label += ` tagged "${activeTag}"`;
if (debouncedSearch) label += ` matching "${debouncedSearch}"`; if (debouncedSearch) label = `${showing} result${showing !== 1 ? 's' : ''} across all folders for "${debouncedSearch}"`;
return label; return label;
})()} })()}
</p> </p>