Remove recorders from cached payload content

This commit is contained in:
DrMint 2024-03-09 10:01:12 +01:00
parent 3c7ce915f1
commit 24f8e72fe9
4 changed files with 12 additions and 25 deletions

View File

@ -1,11 +1,11 @@
--- ---
import { formatRecorder } from "src/utils/format"; import type { EndpointRecorder } from "src/shared/payload/payload-sdk";
import Metadata from "./Metadata.astro"; import Metadata from "./Metadata.astro";
interface Props { interface Props {
translators?: string[] | undefined; translators?: EndpointRecorder[] | undefined;
transcribers?: string[] | undefined; transcribers?: EndpointRecorder[] | undefined;
proofreaders?: string[] | undefined; proofreaders?: EndpointRecorder[] | undefined;
} }
const { translators = [], transcribers = [], proofreaders = [] } = Astro.props; const { translators = [], transcribers = [], proofreaders = [] } = Astro.props;
@ -16,17 +16,17 @@ const { translators = [], transcribers = [], proofreaders = [] } = Astro.props;
<Metadata <Metadata
icon="material-symbols:person-outline" icon="material-symbols:person-outline"
title="Translators" title="Translators"
values={translators.map((id) => formatRecorder(id))} values={translators.map(({ username }) => username)}
/> />
<Metadata <Metadata
icon="material-symbols:person-edit-outline" icon="material-symbols:person-edit-outline"
title="Transcribers" title="Transcribers"
values={transcribers.map((id) => formatRecorder(id))} values={transcribers.map(({ username }) => username)}
/> />
<Metadata <Metadata
icon="material-symbols:person-check-outline" icon="material-symbols:person-check-outline"
title="Proofreaders" title="Proofreaders"
values={proofreaders.map((id) => formatRecorder(id))} values={proofreaders.map(({ username }) => username)}
/> />

View File

@ -1491,7 +1491,7 @@ export type EndpointPagePreview = {
slug: string; slug: string;
type: PageType; type: PageType;
thumbnail?: PayloadImage; thumbnail?: PayloadImage;
authors: string[]; authors: EndpointRecorder[];
tagGroups: TagGroup[]; tagGroups: TagGroup[];
translations: { translations: {
language: string; language: string;
@ -1508,9 +1508,9 @@ export type EndpointPage = EndpointPagePreview & {
sourceLanguage: string; sourceLanguage: string;
summary?: RichTextContent; summary?: RichTextContent;
content: RichTextContent; content: RichTextContent;
transcribers: string[]; transcribers: EndpointRecorder[];
translators: string[]; translators: EndpointRecorder[];
proofreaders: string[]; proofreaders: EndpointRecorder[];
toc: TableOfContentEntry[]; toc: TableOfContentEntry[];
})[]; })[];
parentPages: ParentPage[]; parentPages: ParentPage[];

View File

@ -1,6 +1,5 @@
import { import {
payload, payload,
type EndpointRecorder,
type Language, type Language,
type EndpointTag, type EndpointTag,
type EndpointTagsGroup, type EndpointTagsGroup,
@ -10,16 +9,14 @@ import {
type Cache = { type Cache = {
locales: Language[]; locales: Language[];
currencies: string[]; currencies: string[];
recorders: EndpointRecorder[]; wordings: EndpointWording[];
tags: EndpointTag[]; tags: EndpointTag[];
tagsGroups: EndpointTagsGroup[]; tagsGroups: EndpointTagsGroup[];
wordings: EndpointWording[];
}; };
const fetchNewData = async (): Promise<Cache> => ({ const fetchNewData = async (): Promise<Cache> => ({
locales: await payload.getLanguages(), locales: await payload.getLanguages(),
currencies: (await payload.getCurrencies()).map(({ id }) => id), currencies: (await payload.getCurrencies()).map(({ id }) => id),
recorders: await payload.getRecorders(),
tags: await payload.getTags(), tags: await payload.getTags(),
tagsGroups: await payload.getTagsGroups(), tagsGroups: await payload.getTagsGroups(),
wordings: await payload.getWordings(), wordings: await payload.getWordings(),

View File

@ -3,16 +3,6 @@ import { cache } from "src/utils/cachedPayload";
export const formatLocale = (code: string): string => export const formatLocale = (code: string): string =>
cache.locales.find(({ id }) => id === code)?.name ?? code; 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 = ({ export const formatInlineTitle = ({
pretitle, pretitle,
title, title,