Reduce requested category data in queries
This commit is contained in:
@@ -22,8 +22,8 @@ import { UpdaterSubscription } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { Progress } from '@/components/util/Progress';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
import { dateTimeFormatter } from '@/util/date.ts';
|
||||
import { TCategory } from '@/typings.ts';
|
||||
import { MediaQuery } from '@/lib/ui/MediaQuery.tsx';
|
||||
import { CategoryIdInfo } from '@/lib/data/Categories.ts';
|
||||
|
||||
const calcProgress = (status: UpdaterSubscription['updateStatusChanged'] | undefined) => {
|
||||
if (!status) {
|
||||
@@ -44,7 +44,7 @@ export function UpdateChecker({
|
||||
categoryId,
|
||||
handleFinishedUpdate,
|
||||
}: {
|
||||
categoryId?: TCategory['id'];
|
||||
categoryId?: CategoryIdInfo['id'];
|
||||
handleFinishedUpdate?: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
@@ -85,7 +85,7 @@ export function UpdateChecker({
|
||||
reFetchLastTimestamp().catch(defaultPromiseErrorHandler('UpdateChecker::reFetchLastTimestamp'));
|
||||
}, [status?.isRunning]);
|
||||
|
||||
const startUpdate = async (category?: TCategory['id']) => {
|
||||
const startUpdate = async (category?: CategoryIdInfo['id']) => {
|
||||
try {
|
||||
lastRunningState = true;
|
||||
await requestManager.startGlobalUpdate(category !== undefined ? [category] : undefined).response;
|
||||
@@ -104,7 +104,7 @@ export function UpdateChecker({
|
||||
}
|
||||
};
|
||||
|
||||
const onClick = async (category?: TCategory['id']) => {
|
||||
const onClick = async (category?: CategoryIdInfo['id']) => {
|
||||
if (isRunning) {
|
||||
stopUpdate();
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,8 @@ import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts
|
||||
import { Mangas } from '@/lib/data/Mangas.ts';
|
||||
import { TManga } from '@/typings.ts';
|
||||
import { awaitConfirmation } from '@/lib/ui/AwaitableDialog.tsx';
|
||||
import { GetCategoriesBaseQuery, GetCategoriesBaseQueryVariables } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { GET_CATEGORIES_BASE } from '@/lib/graphql/queries/CategoryQuery.ts';
|
||||
|
||||
export const useManageMangaLibraryState = (
|
||||
manga: Pick<TManga, 'id' | 'title' | 'inLibrary'>,
|
||||
@@ -87,9 +89,16 @@ export const useManageMangaLibraryState = (
|
||||
return;
|
||||
}
|
||||
|
||||
let categories: Awaited<ReturnType<typeof requestManager.getCategories>['response']>;
|
||||
let categories: Awaited<
|
||||
ReturnType<
|
||||
typeof requestManager.getCategories<GetCategoriesBaseQuery, GetCategoriesBaseQueryVariables>
|
||||
>['response']
|
||||
>;
|
||||
try {
|
||||
categories = await requestManager.getCategories().response;
|
||||
categories = await requestManager.getCategories<
|
||||
GetCategoriesBaseQuery,
|
||||
GetCategoriesBaseQueryVariables
|
||||
>(GET_CATEGORIES_BASE).response;
|
||||
} catch (e) {
|
||||
makeToast(t('category.error.label.request_failure'), 'error');
|
||||
return;
|
||||
|
||||
@@ -25,6 +25,8 @@ import { CheckboxInput } from '@/components/atoms/CheckboxInput.tsx';
|
||||
import { makeToast } from '@/components/util/Toast.tsx';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
import { updateMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts';
|
||||
import { GetCategoriesBaseQuery, GetCategoriesBaseQueryVariables } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { GET_CATEGORIES_BASE } from '@/lib/graphql/queries/CategoryQuery.ts';
|
||||
|
||||
type BaseProps = {
|
||||
open: boolean;
|
||||
@@ -88,7 +90,9 @@ export function CategorySelect(props: CategorySelectProps) {
|
||||
const [doNotShowAddToLibraryDialogAgain, setDoNotShowAddToLibraryDialogAgain] = useState(false);
|
||||
|
||||
const mangaCategoryIds = useGetMangaCategoryIds(mangaId);
|
||||
const { data } = requestManager.useGetCategories();
|
||||
const { data } = requestManager.useGetCategories<GetCategoriesBaseQuery, GetCategoriesBaseQueryVariables>(
|
||||
GET_CATEGORIES_BASE,
|
||||
);
|
||||
const categoriesData = data?.categories.nodes;
|
||||
|
||||
const allCategories = useMemo(() => Categories.getUserCreated(categoriesData ?? []), [categoriesData]);
|
||||
|
||||
@@ -20,7 +20,6 @@ import { t as translate } from 'i18next';
|
||||
import { ThreeStateCheckboxInput } from '@/components/atoms/ThreeStateCheckboxInput.tsx';
|
||||
import { makeToast } from '@/components/util/Toast.tsx';
|
||||
import { IncludeOrExclude } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { TCategory } from '@/typings.ts';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { CheckboxContainer } from '@/components/settings/globalUpdate/CheckboxContainer.ts';
|
||||
import {
|
||||
@@ -78,7 +77,7 @@ const getCategoryUpdateInfo = (
|
||||
return categories.map((category) => category.name).join(', ');
|
||||
};
|
||||
|
||||
type CategoryIncludeField = keyof Pick<TCategory, 'includeInUpdate' | 'includeInDownload'>;
|
||||
type CategoryIncludeField = keyof Pick<CategoryType, 'includeInUpdate' | 'includeInDownload'>;
|
||||
|
||||
export type CategoriesInclusionSettingProps = {
|
||||
categories: CategoryType[];
|
||||
|
||||
Reference in New Issue
Block a user