Load only category mangas that are in the library
This commit is contained in:
@@ -63,8 +63,6 @@ import {
|
|||||||
GetAboutQueryVariables,
|
GetAboutQueryVariables,
|
||||||
GetCategoriesQuery,
|
GetCategoriesQuery,
|
||||||
GetCategoriesQueryVariables,
|
GetCategoriesQueryVariables,
|
||||||
GetCategoryMangasQuery,
|
|
||||||
GetCategoryMangasQueryVariables,
|
|
||||||
GetChapterPagesFetchMutation,
|
GetChapterPagesFetchMutation,
|
||||||
GetChapterPagesFetchMutationVariables,
|
GetChapterPagesFetchMutationVariables,
|
||||||
GetChaptersQuery,
|
GetChaptersQuery,
|
||||||
@@ -81,6 +79,8 @@ import {
|
|||||||
GetMangaFetchMutationVariables,
|
GetMangaFetchMutationVariables,
|
||||||
GetMangaQuery,
|
GetMangaQuery,
|
||||||
GetMangaQueryVariables,
|
GetMangaQueryVariables,
|
||||||
|
GetMangasQuery,
|
||||||
|
GetMangasQueryVariables,
|
||||||
GetSourceMangasFetchMutation,
|
GetSourceMangasFetchMutation,
|
||||||
GetSourceMangasFetchMutationVariables,
|
GetSourceMangasFetchMutationVariables,
|
||||||
GetSourceQuery,
|
GetSourceQuery,
|
||||||
@@ -156,8 +156,8 @@ import {
|
|||||||
UPDATE_MANGA,
|
UPDATE_MANGA,
|
||||||
UPDATE_MANGA_CATEGORIES,
|
UPDATE_MANGA_CATEGORIES,
|
||||||
} from '@/lib/graphql/mutations/MangaMutation.ts';
|
} from '@/lib/graphql/mutations/MangaMutation.ts';
|
||||||
import { GET_MANGA } from '@/lib/graphql/queries/MangaQuery.ts';
|
import { GET_MANGA, GET_MANGAS } from '@/lib/graphql/queries/MangaQuery.ts';
|
||||||
import { GET_CATEGORIES, GET_CATEGORY_MANGAS } from '@/lib/graphql/queries/CategoryQuery.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 { GET_SOURCE_MANGAS_FETCH, UPDATE_SOURCE_PREFERENCES } from '@/lib/graphql/mutations/SourceMutation.ts';
|
||||||
import {
|
import {
|
||||||
CLEAR_DOWNLOADER,
|
CLEAR_DOWNLOADER,
|
||||||
@@ -1139,6 +1139,13 @@ export class RequestManager {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public useGetMangas(
|
||||||
|
variables: GetMangasQueryVariables,
|
||||||
|
options?: QueryHookOptions<GetMangasQuery, GetMangasQueryVariables>,
|
||||||
|
): AbortableApolloUseQueryResponse<GetMangasQuery, GetMangasQueryVariables> {
|
||||||
|
return this.doRequest(GQLMethod.USE_QUERY, GET_MANGAS, variables, options);
|
||||||
|
}
|
||||||
|
|
||||||
public getMangaThumbnailUrl(mangaId: number): string {
|
public getMangaThumbnailUrl(mangaId: number): string {
|
||||||
return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`);
|
return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`);
|
||||||
}
|
}
|
||||||
@@ -1475,9 +1482,9 @@ export class RequestManager {
|
|||||||
|
|
||||||
public useGetCategoryMangas(
|
public useGetCategoryMangas(
|
||||||
id: number,
|
id: number,
|
||||||
options?: QueryHookOptions<GetCategoryMangasQuery, GetCategoryMangasQueryVariables>,
|
options?: QueryHookOptions<GetMangasQuery, GetMangasQueryVariables>,
|
||||||
): AbortableApolloUseQueryResponse<GetCategoryMangasQuery, GetCategoryMangasQueryVariables> {
|
): AbortableApolloUseQueryResponse<GetMangasQuery, GetMangasQueryVariables> {
|
||||||
return this.doRequest(GQLMethod.USE_QUERY, GET_CATEGORY_MANGAS, { id }, options);
|
return this.useGetMangas({ condition: { inLibrary: true, categoryIds: [id] } }, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteCategory(
|
public deleteCategory(
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export default function Library() {
|
|||||||
error: mangaError,
|
error: mangaError,
|
||||||
loading: mangaLoading,
|
loading: mangaLoading,
|
||||||
} = requestManager.useGetCategoryMangas(activeTab?.id, { skip: !activeTab, nextFetchPolicy: 'cache-only' });
|
} = 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);
|
const { setTitle, setAction } = useContext(NavbarContext);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user