fixed search

This commit is contained in:
DevOFVictory
2025-11-12 19:25:21 +01:00
parent b287f19686
commit 9516642beb
2 changed files with 32 additions and 7 deletions

View File

@@ -39,7 +39,6 @@ export default function ExploreScreen() {
data: results = [],
error,
refetch,
// isLoading, // optional, falls benötigt
} = useSearch(tagStrings as string[]);
// Lokaler Show-Cache
@@ -67,7 +66,7 @@ export default function ExploreScreen() {
for (const r of results) {
if (r.type === "SHOW") {
const uiShow = mapApiShowToUI(r.data);
if (uiShow.showId != null) fromResults[Number(uiShow.showId)] = uiShow as Show;
if (uiShow?.showId != null) fromResults[Number(uiShow.showId)] = uiShow as Show;
}
}
if (Object.keys(fromResults).length) {
@@ -135,6 +134,23 @@ export default function ExploreScreen() {
.sort((a, b) => (a.name || "").localeCompare(b.name || ""));
}, [results]);
// SHOW-Resultate, die KEINE Staffeln haben -> als einzelne ShowBox anzeigen
const standaloneShows: Show[] = React.useMemo(() => {
const seen = new Set<number>();
const list: Show[] = [];
for (const r of results) {
if (r.type !== "SHOW") continue;
const ui = mapApiShowToUI(r.data) as Show | undefined;
if (!ui?.id) continue;
const id = Number(ui.id);
if (seasonsByShowId.has(id)) continue; // bereits als Carousel vorhanden -> nicht doppelt
if (seen.has(id)) continue;
seen.add(id);
list.push(ui);
}
return list;
}, [results, seasonsByShowId]);
// Moderner Fehlerblock
if (error) {
return (
@@ -195,7 +211,8 @@ export default function ExploreScreen() {
);
}
const noResults = persons.length === 0 && seasonsByShowId.size === 0;
const noResults =
persons.length === 0 && seasonsByShowId.size === 0 && standaloneShows.length === 0;
return (
<View style={[styles.mainContainer]}>
@@ -301,10 +318,11 @@ export default function ExploreScreen() {
)}
<View style={styles.sectionContainer}>
{seasonsByShowId.size > 0 && (
<Text style={styles.sectionTitle}>Staffeln</Text>
{(seasonsByShowId.size > 0 || standaloneShows.length > 0) && (
<Text style={styles.sectionTitle}>Staffeln &amp; Shows</Text>
)}
{/* Carousels für Shows mit Staffeln */}
{Array.from(seasonsByShowId.entries()).map(([showId, seasons]) => {
const show = showsById[Number(showId)];
if (!seasons || seasons.length === 0) return null;
@@ -355,6 +373,13 @@ export default function ExploreScreen() {
);
})}
{/* Einzelne Shows (ohne Staffeln) */}
{standaloneShows.map((show) => (
<View key={`show-${show.id}`} style={{ marginTop: 12 }}>
<ShowBox show={show} shadow={false} />
</View>
))}
{/* Schöner Empty-State */}
{noResults && (
<View