Reader settings
This commit is contained in:
@@ -31,14 +31,19 @@ export const convertValueFromMetadata = <T extends AllowedMetadataValueTypes = A
|
||||
return value as T;
|
||||
};
|
||||
|
||||
export const convertFromGqlMeta = (gqlMetadata?: MetaType[]): Metadata | undefined => {
|
||||
export const convertFromGqlMeta = (
|
||||
gqlMetadata?: MetaType[],
|
||||
filter: (key: string) => boolean = () => true,
|
||||
): Metadata | undefined => {
|
||||
if (!gqlMetadata) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const metadata: Metadata = {};
|
||||
gqlMetadata.forEach(({ key, value }) => {
|
||||
metadata[key] = value;
|
||||
if (filter(key)) {
|
||||
metadata[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return metadata;
|
||||
|
||||
@@ -42,7 +42,7 @@ import { ChapterIdInfo } from '@/modules/chapter/services/Chapters.ts';
|
||||
import { CategoryIdInfo } from '@/modules/category/Category.types.ts';
|
||||
import { SourceType } from '@/lib/graphql/generated/graphql.ts';
|
||||
|
||||
export const extractOriginalKey = (key: string): string => key.split('_').slice(-1)[0];
|
||||
export const extractOriginalKey = (key: string) => key.split('_').slice(-1)[0];
|
||||
|
||||
export const getMetadataKey = (key: string, appPrefix: string = APP_METADATA_KEY_PREFIX) => {
|
||||
const isGlobalMetadataKey = GLOBAL_METADATA_KEYS.includes(key as AppMetadataKeys);
|
||||
|
||||
Reference in New Issue
Block a user