a tool for shared writing and social publishing

fix update pub function and icon in edit form

+7 -4
+1 -1
app/lish/createPub/UpdatePubForm.tsx
··· 31 31 setDescriptionValue(record.description || ""); 32 32 if (record.icon) 33 33 setIconPreview( 34 - `url(/api/atproto_images?did=${pubData.identity_did}&cid=${(record.icon.ref as unknown as { $link: string })["$link"]})`, 34 + `/api/atproto_images?did=${pubData.identity_did}&cid=${(record.icon.ref as unknown as { $link: string })["$link"]}`, 35 35 ); 36 36 }, [pubData]); 37 37 let toast = useToaster();
+6 -3
app/lish/createPub/updatePublication.ts
··· 6 6 import { supabaseServerClient } from "supabase/serverClient"; 7 7 import { Json } from "supabase/database.types"; 8 8 import { AtUri } from "@atproto/syntax"; 9 + import { redirect } from "next/navigation"; 9 10 10 11 export async function updatePublication({ 11 12 uri, ··· 31 32 .select("*") 32 33 .eq("uri", uri) 33 34 .single(); 34 - if (!existingPub || existingPub.identity_did! === identity.atp_did) return; 35 + if (!existingPub || existingPub.identity_did !== identity.atp_did) return; 35 36 let aturi = new AtUri(existingPub.uri); 36 37 37 38 let record: PubLeafletPublication.Record = { 38 39 $type: "pub.leaflet.publication", 39 - name, 40 40 ...(existingPub.record as object), 41 + name, 41 42 }; 42 43 43 44 if (description) { ··· 66 67 }); 67 68 68 69 //optimistically write to our db! 69 - let { data: publication } = await supabaseServerClient 70 + let { data: publication, error } = await supabaseServerClient 70 71 .from("publications") 71 72 .update({ 72 73 name: record.name, ··· 75 76 .eq("uri", uri) 76 77 .select() 77 78 .single(); 79 + if (name !== existingPub.name) 80 + return redirect(`/lish/${aturi.host}/${name}/dashboard`); 78 81 79 82 return { success: true, publication }; 80 83 }