diff --git a/app/(tabs)/explore.tsx b/app/(tabs)/explore.tsx index 2d5b0d8..13cae0e 100644 --- a/app/(tabs)/explore.tsx +++ b/app/(tabs)/explore.tsx @@ -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(); + 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 ( @@ -301,10 +318,11 @@ export default function ExploreScreen() { )} - {seasonsByShowId.size > 0 && ( - Staffeln + {(seasonsByShowId.size > 0 || standaloneShows.length > 0) && ( + Staffeln & Shows )} + {/* 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) => ( + + + + ))} + {/* Schöner Empty-State */} {noResults && (