From 57e995365a480d63642a070074524f0e930cf735 Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Tue, 18 Nov 2025 18:04:06 -0500 Subject: [PATCH] render standalone published docs properly on homepage --- actions/getIdentityData.ts | 1 + app/(home-pages)/home/HomeLayout.tsx | 13 ++++++++++--- components/Pages/PublicationMetadata.tsx | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/actions/getIdentityData.ts b/actions/getIdentityData.ts index 7224413b..e50cd2db 100644 --- a/actions/getIdentityData.ts +++ b/actions/getIdentityData.ts @@ -29,6 +29,7 @@ export async function uncachedGetIdentityData() { id, root_entity, permission_token_rights(*), + leaflets_to_documents(*, documents(*)), leaflets_in_publications(*, publications(*), documents(*)) ) ) diff --git a/app/(home-pages)/home/HomeLayout.tsx b/app/(home-pages)/home/HomeLayout.tsx index d7d55166..4f731b95 100644 --- a/app/(home-pages)/home/HomeLayout.tsx +++ b/app/(home-pages)/home/HomeLayout.tsx @@ -231,10 +231,15 @@ export function LeafletList(props: { title={props?.titles?.[leaflet.root_entity] || "Untitled"} token={leaflet} draft={!!leaflet.leaflets_in_publications?.length} - published={!!leaflet.leaflets_in_publications?.find((l) => l.doc)} + published={ + !!leaflet.leaflets_in_publications?.find((l) => l.doc) || + !!leaflet.leaflets_to_documents?.find((l) => !!l.documents) + } publishedAt={ leaflet.leaflets_in_publications?.find((l) => l.doc)?.documents - ?.indexed_at + ?.indexed_at || + leaflet.leaflets_to_documents?.find((l) => !!l.documents) + ?.documents?.indexed_at } leaflet_id={leaflet.root_entity} loggedIn={!!identity} @@ -286,7 +291,9 @@ function useSearchedLeaflets( let allTemplates = useTemplateState((s) => s.templates); let filteredLeaflets = sortedLeaflets.filter(({ token: leaflet }) => { - let published = !!leaflet.leaflets_in_publications?.find((l) => l.doc); + let published = + !!leaflet.leaflets_in_publications?.find((l) => l.doc) || + !!leaflet.leaflets_to_documents?.find((l) => l.document); let drafts = !!leaflet.leaflets_in_publications?.length && !published; let docs = !leaflet.leaflets_in_publications?.length; let templates = !!allTemplates.find((t) => t.id === leaflet.id); diff --git a/components/Pages/PublicationMetadata.tsx b/components/Pages/PublicationMetadata.tsx index 21d65873..99274bed 100644 --- a/components/Pages/PublicationMetadata.tsx +++ b/components/Pages/PublicationMetadata.tsx @@ -175,7 +175,7 @@ export const PublicationMetadataPreview = () => { let record = pub?.documents?.data as PubLeafletDocument.Record | null; let publishedAt = record?.publishedAt; - if (!pub || !pub.publications) return null; + if (!pub) return null; return (
-- 2.51.2