Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
5rahim committed Apr 1, 2024
1 parent 730740d commit fe933c8
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/api/anilist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
3 changes: 3 additions & 0 deletions internal/handlers/manga.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
61 changes: 61 additions & 0 deletions seanime-web/src/app/(main)/manga/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -62,6 +65,8 @@ export default function Page() {
</h2>

<TrendingManga />

<SearchManga />
</div>

</PageWrapper>
Expand Down Expand Up @@ -135,6 +140,62 @@ function TrendingManga() {
)
}

const mangaSearchInputAtom = atom<string>("")

function SearchManga() {
const [searchInput, setSearchInput] = useAtom(mangaSearchInputAtom)
const search = useDebounce(searchInput, 500)

const { data, isLoading, isFetching } = useSeaQuery<ListMangaQuery>({
queryKey: ["search-manga", search],
endpoint: SeaEndpoints.MANGA_ANILIST_LIST_MANGA,
method: "post",
data: {
page: 1,
perPage: 10,
search: search,
},
})

return (
<div className="space-y-4">
<div className="container">
<TextInput
leftIcon={<FiSearch />}
value={searchInput}
onValueChange={v => {
setSearchInput(v)
}}
className="rounded-full"
placeholder="Search manga"
/>
</div>

{!!search && <Carousel
className="w-full max-w-full"
gap="md"
opts={{
align: "start",
}}
autoScroll
>
<CarouselContent className="px-6">
{!(isLoading || isFetching) ? data?.Page?.media?.filter(Boolean).map(media => {
return (
<AnimeListItem
key={media.id}
media={media}
containerClassName="basis-[200px] md:basis-[250px] mx-2 my-8"
isManga
/>
)
}) : [...Array(10).keys()].map((v, idx) => <AnimeSliderSkeletonItem key={idx} />)}
</CarouselContent>
</Carousel>}
</div>
)
}


function GenreSelector() {

Expand Down

0 comments on commit fe933c8

Please sign in to comment.