a tool for shared writing and social publishing
0

Configure Feed

Select the types of activity you want to include in your feed.

fix bsky post ref and tag in update flow

Jared Pereira (Mar 24, 2026, 6:56 PM -0700) d1c1952a 1561298a

+35 -13
+30 -11
actions/publishToPublication.ts
··· 182 182 credentialSession.did!, 183 183 ); 184 184 185 - let existingRecord: Partial<PubLeafletDocument.Record> = {}; 185 + let existingRecord: Partial<SiteStandardDocument.Record> = {}; 186 186 const normalizedDoc = normalizeDocumentRecord(draft?.documents?.data); 187 187 if (normalizedDoc) { 188 188 // When reading existing data, use normalized format to extract fields ··· 194 194 tags: normalizedDoc.tags, 195 195 coverImage: normalizedDoc.coverImage, 196 196 theme: normalizedDoc.theme, 197 + bskyPostRef: normalizedDoc.bskyPostRef, 197 198 }; 198 199 } 199 200 ··· 249 250 // Determine the rkey early since we need it for the path field 250 251 const rkey = existingDocUri ? new AtUri(existingDocUri).rkey : TID.nextStr(); 251 252 253 + // Resolve fields: use new values if provided, otherwise preserve existing 254 + const resolvedDescription = 255 + description !== undefined ? description : existingRecord.description; 256 + const resolvedTags = tags !== undefined ? tags : existingRecord.tags; 257 + const resolvedCoverImage = coverImageBlob ?? existingRecord.coverImage; 258 + const resolvedPublishedAt = 259 + publishedAt || existingRecord.publishedAt || new Date().toISOString(); 260 + 252 261 // Create record based on the document type 253 262 let record: PubLeafletDocument.Record | SiteStandardDocument.Record; 254 263 ··· 263 272 title: title || "", 264 273 site: siteUri, 265 274 path: "/" + rkey, 266 - publishedAt: 267 - publishedAt || existingRecord.publishedAt || new Date().toISOString(), 268 - ...(description && { description }), 269 - ...(tags !== undefined && { tags }), 270 - ...(coverImageBlob && { coverImage: coverImageBlob }), 275 + publishedAt: resolvedPublishedAt, 276 + ...(resolvedDescription !== undefined && { 277 + description: resolvedDescription, 278 + }), 279 + ...(resolvedTags !== undefined && { tags: resolvedTags }), 280 + ...(resolvedCoverImage && { coverImage: resolvedCoverImage }), 281 + ...(existingRecord.bskyPostRef && { 282 + bskyPostRef: existingRecord.bskyPostRef, 283 + }), 271 284 // Include theme for standalone documents (not for publication documents) 272 285 ...(!publication_uri && theme && { theme }), 273 286 ...(preferences && { ··· 295 308 }, 296 309 }), 297 310 title: title || "", 298 - description: description || "", 299 - ...(tags !== undefined && { tags }), 300 - ...(coverImageBlob && { coverImage: coverImageBlob }), 311 + description: resolvedDescription || "", 312 + ...(resolvedTags !== undefined && { tags: resolvedTags }), 313 + ...(resolvedCoverImage && { coverImage: resolvedCoverImage }), 314 + ...(existingRecord.bskyPostRef && { 315 + postRef: existingRecord.bskyPostRef, 316 + }), 301 317 pages: pagesArray, 302 - publishedAt: 303 - publishedAt || existingRecord.publishedAt || new Date().toISOString(), 318 + publishedAt: resolvedPublishedAt, 304 319 } satisfies PubLeafletDocument.Record; 305 320 } 306 321 ··· 332 347 publication: publication_uri, 333 348 title: title, 334 349 description: description, 350 + tags: resolvedTags ?? [], 351 + cover_image: cover_image ?? null, 335 352 }), 336 353 ]); 337 354 } else { ··· 341 358 document: result.uri, 342 359 title: title || "", 343 360 description: description || "", 361 + tags: resolvedTags ?? [], 362 + cover_image: cover_image ?? null, 344 363 }); 345 364 346 365 // Heuristic: Remove title entities if this is the first time publishing standalone
+5 -2
app/[leaflet_id]/actions/PublishButton.tsx
··· 65 65 66 66 const UpdateButton = () => { 67 67 let [isLoading, setIsLoading] = useState(false); 68 - let { data: pub, mutate } = useLeafletPublicationData(); 68 + let { data: pub, mutate, normalizedDocument } = useLeafletPublicationData(); 69 69 let { permission_token, rootEntity, rep } = useReplicache(); 70 70 let { identity } = useIdentityData(); 71 71 let toaster = useToaster(); ··· 88 88 : pub?.description || ""; 89 89 90 90 // Get tags from Replicache state (same as draft editor) 91 + // Fall back to normalized document tags if Replicache hasn't pulled yet 91 92 let tags = useSubscribe(rep, (tx) => tx.get<string[]>("publication_tags")); 92 - const currentTags = Array.isArray(tags) ? tags : []; 93 + const currentTags = Array.isArray(tags) 94 + ? tags 95 + : normalizedDocument?.tags ?? []; 93 96 94 97 // Get cover image from Replicache state 95 98 let coverImage = useSubscribe(rep, (tx) =>