From cee48ecf654fc1976b1aa1771c233e18b865bee4 Mon Sep 17 00:00:00 2001 From: Rudy Fraser Date: Thu, 2 Jul 2026 19:30:33 -0400 Subject: [PATCH] fix(community-posts): reliably delete both the stub and appview copy Ordered the two deletes stub-first then appview-copy, both idempotent (deleteRecord no-ops on a missing record, appview PostNotFound counts as success). A failure now surfaces for retry instead of silently orphaning the PDS stub, and a retry converges to both being gone. --- src/state/queries/post.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts index fed8ddcf4..7b936299a 100644 --- a/src/state/queries/post.ts +++ b/src/state/queries/post.ts @@ -358,29 +358,26 @@ export function usePostDeleteMutation() { mutationFn: async ({uri}) => { const parsedUri = new AtUri(uri) if (parsedUri.collection === COMMUNITY_POST_COLLECTION) { - // Delete from community DB via appview + // Both deletes are idempotent, so ordering is safe and a retry after + // any partial failure converges to both being gone. Remove the PDS + // stub first (deleteRecord is a no-op if already absent)... + await agent.com.atproto.repo.deleteRecord({ + repo: parsedUri.hostname, + collection: COMMUNITY_POST_COLLECTION, + rkey: parsedUri.rkey, + }) + // ...then the appview copy, treating already-gone as success. const res = await communityXrpc( agent, 'community.blacksky.feed.deletePost', {body: {uri}}, ) - // A post already gone from the appview is a successful outcome — a - // retry after a partial failure must not surface as an error. if (!res.ok) { const err = (await res.json().catch(() => ({}))) as {error?: string} if (err.error !== 'PostNotFound') { throw new Error(err.error || `deletePost failed: ${res.status}`) } } - // Best-effort: the appview is the source of truth for community - // post visibility; a failed stub delete must not strand the delete. - await agent.com.atproto.repo - .deleteRecord({ - repo: parsedUri.hostname, - collection: COMMUNITY_POST_COLLECTION, - rkey: parsedUri.rkey, - }) - .catch(() => {}) } else { await agent.deletePost(uri) } -- knotmirror 0.0.1