Use gql for "global metadata"

This commit is contained in:
schroda
2023-09-01 20:24:40 +02:00
parent b9480736c3
commit 80cb06dfd5
4 changed files with 48 additions and 13 deletions

View File

@@ -20,6 +20,7 @@ import {
MetadataKeyValuePair,
} from '@/typings';
import requestManager, { RequestManager } from '@/lib/requests/RequestManager.ts';
import { MetaType } from '@/lib/graphql/generated/graphql.ts';
const APP_METADATA_KEY_PREFIX = 'webUI_';
@@ -362,3 +363,16 @@ export const requestUpdateCategoryMetadata = async (
category: ICategory,
keysToValues: MetadataKeyValuePair[],
): Promise<void[]> => requestUpdateMetadata(category, 'category', keysToValues);
export const convertGqlMetadata = (gqlMetadata?: MetaType[]): Metadata | undefined => {
if (!gqlMetadata) {
return undefined;
}
const metadata: Metadata = {};
gqlMetadata.forEach(({ key, value }) => {
metadata[key] = value;
});
return metadata;
};