diff --git a/internal/api/anilist/list.go b/internal/api/anilist/list.go index 39b2bfbb..05e748dc 100644 --- a/internal/api/anilist/list.go +++ b/internal/api/anilist/list.go @@ -384,7 +384,7 @@ const ListMangaQuery = `query ListManga( currentPage lastPage }, - media(type: MANGA, search: $search, sort: $sort, status_in: $status, format: $format, genre_in: $genres, averageScore_greater: $averageScore_greater, season: $season, seasonYear: $seasonYear, format_not: MUSIC){ + media(type: MANGA, isAdult: false, search: $search, sort: $sort, status_in: $status, format: $format, genre_in: $genres, averageScore_greater: $averageScore_greater, season: $season, seasonYear: $seasonYear, format_not: MUSIC){ ...basicManga } } diff --git a/internal/handlers/manga.go b/internal/handlers/manga.go index 1a4cd326..5e417e21 100644 --- a/internal/handlers/manga.go +++ b/internal/handlers/manga.go @@ -104,6 +104,9 @@ func HandleGetMangaEntry(c *RouteCtx) error { AnilistClientWrapper: c.App.AnilistClientWrapper, MangaCollection: collection, }) + if err != nil { + return c.RespondWithError(err) + } baseMangaCache.SetT(entry.MediaId, entry.Media, time.Hour) diff --git a/seanime-web/src/app/(main)/manga/page.tsx b/seanime-web/src/app/(main)/manga/page.tsx index 2d0f1073..c9624c48 100644 --- a/seanime-web/src/app/(main)/manga/page.tsx +++ b/seanime-web/src/app/(main)/manga/page.tsx @@ -10,6 +10,8 @@ import { Carousel, CarouselContent, CarouselDotButtons } from "@/components/ui/c import { HorizontalDraggableScroll } from "@/components/ui/horizontal-draggable-scroll" import { Skeleton } from "@/components/ui/skeleton" import { StaticTabs } from "@/components/ui/tabs" +import { TextInput } from "@/components/ui/text-input" +import { useDebounce } from "@/hooks/use-debounce" import { ListMangaQuery } from "@/lib/anilist/gql/graphql" import { SeaEndpoints } from "@/lib/server/endpoints" import { useSeaQuery } from "@/lib/server/query" @@ -18,6 +20,7 @@ import { ThemeLibraryScreenBannerType, useThemeSettings } from "@/lib/theme/hook import { atom } from "jotai/index" import { useAtom, useAtomValue } from "jotai/react" import React, { memo } from "react" +import { FiSearch } from "react-icons/fi" export default function Page() { const { mangaCollection, mangaCollectionLoading } = useMangaCollection() @@ -62,6 +65,8 @@ export default function Page() { + + @@ -135,6 +140,62 @@ function TrendingManga() { ) } +const mangaSearchInputAtom = atom("") + +function SearchManga() { + const [searchInput, setSearchInput] = useAtom(mangaSearchInputAtom) + const search = useDebounce(searchInput, 500) + + const { data, isLoading, isFetching } = useSeaQuery({ + queryKey: ["search-manga", search], + endpoint: SeaEndpoints.MANGA_ANILIST_LIST_MANGA, + method: "post", + data: { + page: 1, + perPage: 10, + search: search, + }, + }) + + return ( +
+
+ } + value={searchInput} + onValueChange={v => { + setSearchInput(v) + }} + className="rounded-full" + placeholder="Search manga" + /> +
+ + {!!search && + + {!(isLoading || isFetching) ? data?.Page?.media?.filter(Boolean).map(media => { + return ( + + ) + }) : [...Array(10).keys()].map((v, idx) => )} + + } +
+ ) +} + function GenreSelector() {