Reduce requested source data in queries
This commit is contained in:
@@ -15,10 +15,9 @@ import {
|
||||
MetadataHolder,
|
||||
MetadataKeyValuePair,
|
||||
TManga,
|
||||
TPartialSource,
|
||||
} from '@/typings.ts';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { MetaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { MetaType, SourceType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { DEFAULT_DEVICE, getActiveDevice } from '@/util/device.ts';
|
||||
import { CategoryIdInfo } from '@/lib/data/Categories.ts';
|
||||
import { ChapterIdInfo } from '@/lib/data/Chapters.ts';
|
||||
@@ -382,7 +381,8 @@ export const requestUpdateMetadataValue = async (
|
||||
await requestManager.setMangaMeta((metadataHolder as TManga).id, metadataKey, value).response;
|
||||
break;
|
||||
case 'source':
|
||||
await requestManager.setSourceMeta((metadataHolder as TPartialSource).id, metadataKey, value).response;
|
||||
await requestManager.setSourceMeta((metadataHolder as Pick<SourceType, 'id'>).id, metadataKey, value)
|
||||
.response;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`requestUpdateMetadataValue: unknown holderType "${holderType}"`);
|
||||
@@ -415,6 +415,6 @@ export const requestUpdateCategoryMetadata = async (
|
||||
): Promise<void[]> => requestUpdateMetadata(category, 'category', keysToValues);
|
||||
|
||||
export const requestUpdateSourceMetadata = async (
|
||||
source: TPartialSource,
|
||||
source: Pick<SourceType, 'id'> & GqlMetaHolder,
|
||||
keysToValue: MetadataKeyValuePair[],
|
||||
): Promise<void[]> => requestUpdateMetadata(source, 'source', keysToValue);
|
||||
|
||||
@@ -13,11 +13,11 @@ import {
|
||||
ISourceMetadata,
|
||||
Metadata,
|
||||
SourceMetadataKeys,
|
||||
TPartialSource,
|
||||
} from '@/typings.ts';
|
||||
import { jsonSaveParse } from '@/util/HelperFunctions.ts';
|
||||
import { convertFromGqlMeta, getMetadataFrom, requestUpdateSourceMetadata } from '@/lib/metadata/metadata.ts';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
import { SourceType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
const convertAppMetadataToGqlMetadata = (
|
||||
metadata: Partial<ISourceMetadata>,
|
||||
@@ -42,7 +42,7 @@ export const updateSourceMetadata = async <
|
||||
MetadataKeys extends SourceMetadataKeys = SourceMetadataKeys,
|
||||
MetadataKey extends MetadataKeys = MetadataKeys,
|
||||
>(
|
||||
source: TPartialSource,
|
||||
source: Pick<SourceType, 'id'> & GqlMetaHolder,
|
||||
metadataKey: MetadataKey,
|
||||
value: ISourceMetadata[MetadataKey],
|
||||
): Promise<void[]> =>
|
||||
@@ -52,7 +52,7 @@ export const updateSourceMetadata = async <
|
||||
|
||||
export const createUpdateSourceMetadata =
|
||||
<Settings extends SourceMetadataKeys>(
|
||||
source: TPartialSource,
|
||||
source: Pick<SourceType, 'id'> & GqlMetaHolder,
|
||||
handleError: (error: any) => void = defaultPromiseErrorHandler('createUpdateSourceMetadata'),
|
||||
): ((...args: OmitFirst<Parameters<typeof updateSourceMetadata<Settings>>>) => Promise<void | void[]>) =>
|
||||
(metadataKey, value) =>
|
||||
|
||||
Reference in New Issue
Block a user