···11+"use server";
22+33+import { AtpBaseClient } from "lexicons/api";
44+import { getIdentityData } from "actions/getIdentityData";
55+import { createOauthClient } from "src/atproto-oauth";
66+import { AtUri } from "@atproto/syntax";
77+import { supabaseServerClient } from "supabase/serverClient";
88+import { revalidatePath } from "next/cache";
99+1010+export async function deletePost(document_uri: string) {
1111+ let identity = await getIdentityData();
1212+ if (!identity || !identity.atp_did) throw new Error("No Identity");
1313+1414+ const oauthClient = await createOauthClient();
1515+ let credentialSession = await oauthClient.restore(identity.atp_did);
1616+ let agent = new AtpBaseClient(
1717+ credentialSession.fetchHandler.bind(credentialSession),
1818+ );
1919+ let uri = new AtUri(document_uri);
2020+ if (uri.host !== identity.atp_did) return;
2121+2222+ await Promise.all([
2323+ agent.pub.leaflet.document.delete({
2424+ repo: credentialSession.did,
2525+ rkey: uri.rkey,
2626+ }),
2727+ supabaseServerClient.from("documents").delete().eq("uri", document_uri),
2828+ supabaseServerClient
2929+ .from("leaflets_in_publications")
3030+ .delete()
3131+ .eq("doc", document_uri),
3232+ ]);
3333+ return revalidatePath("/lish/[did]/[publication]/dashboard", "layout");
3434+}
+1-1
app/lish/createPub/UpdatePubForm.tsx
···134134};
135135136136export function CustomDomainForm() {
137137- let pubData = usePublicationData();
137137+ let { data: pubData } = usePublicationData();
138138 if (!pubData) return null;
139139 let record = pubData?.record as PubLeafletPublication.Record;
140140 let [state, setState] = useState<