From 563473b1175dd969e8746300eba96e1e67152d54 Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Wed, 19 Nov 2025 12:27:36 -0500 Subject: [PATCH] delete entiteis before publishing --- actions/publishToPublication.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/actions/publishToPublication.ts b/actions/publishToPublication.ts index 3ce55907..1f53d7cc 100644 --- a/actions/publishToPublication.ts +++ b/actions/publishToPublication.ts @@ -103,6 +103,15 @@ export async function publishToPublication({ existingDocUri = draft?.document; } + // Heuristic: Remove title entities if this is the first time publishing + // (when coming from a standalone leaflet with entitiesToDelete passed in) + if (entitiesToDelete && entitiesToDelete.length > 0 && !existingDocUri) { + await supabaseServerClient + .from("entities") + .delete() + .in("id", entitiesToDelete); + } + let { data } = await supabaseServerClient.rpc("get_facts", { root: root_entity, }); @@ -187,15 +196,6 @@ export async function publishToPublication({ .eq("leaflet", leaflet_id) .eq("publication", publication_uri), ]); - - // Heuristic: Remove title entities if this is the first time publishing - // (when coming from a standalone leaflet with entitiesToDelete passed in) - if (entitiesToDelete && entitiesToDelete.length > 0 && !existingDocUri) { - await supabaseServerClient - .from("entities") - .delete() - .in("id", entitiesToDelete); - } } else { // Publishing standalone - update leaflets_to_documents await supabaseServerClient.from("leaflets_to_documents").upsert({ -- 2.51.2