From b6382bb33af231ac37810ea338d44e0f79429d2c Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Thu, 19 Oct 2023 21:01:21 +0200 Subject: [PATCH] Load only category mangas that are in the library --- src/lib/requests/RequestManager.ts | 21 ++++++++++++++------- src/screens/Library.tsx | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index d4f75862..bb6b81df 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -63,8 +63,6 @@ import { GetAboutQueryVariables, GetCategoriesQuery, GetCategoriesQueryVariables, - GetCategoryMangasQuery, - GetCategoryMangasQueryVariables, GetChapterPagesFetchMutation, GetChapterPagesFetchMutationVariables, GetChaptersQuery, @@ -81,6 +79,8 @@ import { GetMangaFetchMutationVariables, GetMangaQuery, GetMangaQueryVariables, + GetMangasQuery, + GetMangasQueryVariables, GetSourceMangasFetchMutation, GetSourceMangasFetchMutationVariables, GetSourceQuery, @@ -156,8 +156,8 @@ import { UPDATE_MANGA, UPDATE_MANGA_CATEGORIES, } from '@/lib/graphql/mutations/MangaMutation.ts'; -import { GET_MANGA } from '@/lib/graphql/queries/MangaQuery.ts'; -import { GET_CATEGORIES, GET_CATEGORY_MANGAS } from '@/lib/graphql/queries/CategoryQuery.ts'; +import { GET_MANGA, GET_MANGAS } from '@/lib/graphql/queries/MangaQuery.ts'; +import { GET_CATEGORIES } from '@/lib/graphql/queries/CategoryQuery.ts'; import { GET_SOURCE_MANGAS_FETCH, UPDATE_SOURCE_PREFERENCES } from '@/lib/graphql/mutations/SourceMutation.ts'; import { CLEAR_DOWNLOADER, @@ -1139,6 +1139,13 @@ export class RequestManager { ); } + public useGetMangas( + variables: GetMangasQueryVariables, + options?: QueryHookOptions, + ): AbortableApolloUseQueryResponse { + return this.doRequest(GQLMethod.USE_QUERY, GET_MANGAS, variables, options); + } + public getMangaThumbnailUrl(mangaId: number): string { return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`); } @@ -1475,9 +1482,9 @@ export class RequestManager { public useGetCategoryMangas( id: number, - options?: QueryHookOptions, - ): AbortableApolloUseQueryResponse { - return this.doRequest(GQLMethod.USE_QUERY, GET_CATEGORY_MANGAS, { id }, options); + options?: QueryHookOptions, + ): AbortableApolloUseQueryResponse { + return this.useGetMangas({ condition: { inLibrary: true, categoryIds: [id] } }, options); } public deleteCategory( diff --git a/src/screens/Library.tsx b/src/screens/Library.tsx index 20150cca..69abf12a 100644 --- a/src/screens/Library.tsx +++ b/src/screens/Library.tsx @@ -84,7 +84,7 @@ export default function Library() { error: mangaError, loading: mangaLoading, } = requestManager.useGetCategoryMangas(activeTab?.id, { skip: !activeTab, nextFetchPolicy: 'cache-only' }); - const mangas = categoryMangaResponse?.category.mangas.nodes ?? []; + const mangas = categoryMangaResponse?.mangas.nodes ?? []; const { setTitle, setAction } = useContext(NavbarContext); useEffect(() => {