From d5a3c4d713e2c949c8db314b9c5eb1ea2b4dd801 Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Sat, 28 Mar 2026 13:48:32 -0700 Subject: [PATCH] filter publications at origin --- actions/getIdentityData.ts | 32 +++++++++++++++++++++++++-- components/ActionBar/Publications.tsx | 14 +----------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/actions/getIdentityData.ts b/actions/getIdentityData.ts index a2c05347..b13f007d 100644 --- a/actions/getIdentityData.ts +++ b/actions/getIdentityData.ts @@ -4,6 +4,8 @@ import { cookies } from "next/headers"; import { supabaseServerClient } from "supabase/serverClient"; import { cache } from "react"; import { deduplicateByUri } from "src/utils/deduplicateRecords"; +import { AtUri } from "@atproto/syntax"; +import { TID } from "@atproto/common"; export const getIdentityData = cache(uncachedGetIdentityData); export async function uncachedGetIdentityData() { let cookieStore = await cookies(); @@ -75,8 +77,11 @@ export async function uncachedGetIdentityData() { .from("publications") .select("*") .eq("identity_did", auth_res.data.identities.atp_did); - // Deduplicate records that may exist under both pub.leaflet and site.standard namespaces - const publications = deduplicateByUri(rawPublications || []); + // Deduplicate records that may exist under both pub.leaflet and site.standard namespaces, + // then filter to only publications created by Leaflet + const publications = deduplicateByUri(rawPublications || []).filter( + isLeafletPublication, + ); return { ...auth_res.data.identities, publications, @@ -92,3 +97,26 @@ export async function uncachedGetIdentityData() { subscription, }; } + +function isLeafletPublication(p: { uri: string; record: unknown }): boolean { + try { + const rkey = new AtUri(p.uri).rkey; + if (!TID.is(rkey)) return false; + } catch { + return false; + } + + const record = p.record as Record | null; + if (!record) return true; + + if (record.preferences?.greengale) return false; + + if ( + record.theme && + record.theme.$type && + record.theme.$type !== "pub.leaflet.publication#theme" + ) + return false; + + return true; +} diff --git a/components/ActionBar/Publications.tsx b/components/ActionBar/Publications.tsx index ad44ea6b..2fa0355f 100644 --- a/components/ActionBar/Publications.tsx +++ b/components/ActionBar/Publications.tsx @@ -66,19 +66,7 @@ export const PublicationButtons = (props: { )} - {identity.publications - ?.filter((p) => { - let record = p.record as any; - if (record.preferences?.greengale) return false; - if ( - record.theme && - record.theme.$type && - record.theme.$type !== "pub.leaflet.publication#theme" - ) - return false; - return true; - }) - .map((d) => { + {identity.publications?.map((d) => { return (