From 24f8e72fe9b5b70943c736e607fd7e80a8cf88c9 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:01:12 +0100 Subject: [PATCH] Remove recorders from cached payload content --- src/components/Credits.astro | 14 +++++++------- src/shared/payload/payload-sdk.ts | 8 ++++---- src/utils/cachedPayload.ts | 5 +---- src/utils/format.ts | 10 ---------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/components/Credits.astro b/src/components/Credits.astro index 2896e6d..8c6b339 100644 --- a/src/components/Credits.astro +++ b/src/components/Credits.astro @@ -1,11 +1,11 @@ --- -import { formatRecorder } from "src/utils/format"; +import type { EndpointRecorder } from "src/shared/payload/payload-sdk"; import Metadata from "./Metadata.astro"; interface Props { - translators?: string[] | undefined; - transcribers?: string[] | undefined; - proofreaders?: string[] | undefined; + translators?: EndpointRecorder[] | undefined; + transcribers?: EndpointRecorder[] | undefined; + proofreaders?: EndpointRecorder[] | undefined; } const { translators = [], transcribers = [], proofreaders = [] } = Astro.props; @@ -16,17 +16,17 @@ const { translators = [], transcribers = [], proofreaders = [] } = Astro.props; formatRecorder(id))} + values={translators.map(({ username }) => username)} /> formatRecorder(id))} + values={transcribers.map(({ username }) => username)} /> formatRecorder(id))} + values={proofreaders.map(({ username }) => username)} /> diff --git a/src/shared/payload/payload-sdk.ts b/src/shared/payload/payload-sdk.ts index 6a571d1..56547b1 100644 --- a/src/shared/payload/payload-sdk.ts +++ b/src/shared/payload/payload-sdk.ts @@ -1491,7 +1491,7 @@ export type EndpointPagePreview = { slug: string; type: PageType; thumbnail?: PayloadImage; - authors: string[]; + authors: EndpointRecorder[]; tagGroups: TagGroup[]; translations: { language: string; @@ -1508,9 +1508,9 @@ export type EndpointPage = EndpointPagePreview & { sourceLanguage: string; summary?: RichTextContent; content: RichTextContent; - transcribers: string[]; - translators: string[]; - proofreaders: string[]; + transcribers: EndpointRecorder[]; + translators: EndpointRecorder[]; + proofreaders: EndpointRecorder[]; toc: TableOfContentEntry[]; })[]; parentPages: ParentPage[]; diff --git a/src/utils/cachedPayload.ts b/src/utils/cachedPayload.ts index 0f3ab55..5302fb3 100644 --- a/src/utils/cachedPayload.ts +++ b/src/utils/cachedPayload.ts @@ -1,6 +1,5 @@ import { payload, - type EndpointRecorder, type Language, type EndpointTag, type EndpointTagsGroup, @@ -10,16 +9,14 @@ import { type Cache = { locales: Language[]; currencies: string[]; - recorders: EndpointRecorder[]; + wordings: EndpointWording[]; tags: EndpointTag[]; tagsGroups: EndpointTagsGroup[]; - wordings: EndpointWording[]; }; const fetchNewData = async (): Promise => ({ locales: await payload.getLanguages(), currencies: (await payload.getCurrencies()).map(({ id }) => id), - recorders: await payload.getRecorders(), tags: await payload.getTags(), tagsGroups: await payload.getTagsGroups(), wordings: await payload.getWordings(), diff --git a/src/utils/format.ts b/src/utils/format.ts index d22cc40..3f65a45 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -3,16 +3,6 @@ import { cache } from "src/utils/cachedPayload"; export const formatLocale = (code: string): string => cache.locales.find(({ id }) => id === code)?.name ?? code; -export const formatRecorder = (recorderId: string): string => { - const result = cache.recorders.find(({ id }) => id === recorderId); - - if (!result) { - return "UNKNOWN"; - } - - return result.username; -}; - export const formatInlineTitle = ({ pretitle, title,