From dcc04d61dfb68ed76bba5750d50a7567b1d53ab4 Mon Sep 17 00:00:00 2001 From: dawn Date: Tue, 15 Sep 2026 05:52:07 +0300 Subject: [PATCH] web: swap on the record cid when deleting a repo Signed-off-by: dawn --- web/src/lib/api/repoSettings.test.ts | 4 +++- web/src/lib/api/repoSettings.ts | 5 +++-- web/src/lib/components/settings/RepoGeneralForm.svelte | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web/src/lib/api/repoSettings.test.ts b/web/src/lib/api/repoSettings.test.ts index 77909d96d..22667f50c 100644 --- a/web/src/lib/api/repoSettings.test.ts +++ b/web/src/lib/api/repoSettings.test.ts @@ -98,7 +98,8 @@ describe("deleteRepo", () => { uri: view.uri, knot: "knot.test", ownerDid: "did:plc:owner", - repoDid: "did:plc:repo" + repoDid: "did:plc:repo", + cid: view.cid }; it("drops the record before the knot repository", async () => { @@ -115,6 +116,7 @@ describe("deleteRepo", () => { await api.deleteRepo(agent, bobbin, location); expect(order).toEqual(["record", "knot"]); + expect(deleteRecord).toHaveBeenCalledWith(agent, "sh.tangled.repo", "core", "bafyold"); expect(call.mock.calls.at(-1)?.[1]).toEqual({ input: { repo: "did:plc:repo", diff --git a/web/src/lib/api/repoSettings.ts b/web/src/lib/api/repoSettings.ts index 2f794ddb4..712a26027 100644 --- a/web/src/lib/api/repoSettings.ts +++ b/web/src/lib/api/repoSettings.ts @@ -1,5 +1,5 @@ import { ok } from "@atcute/client"; -import type { Nsid, ResourceUri } from "@atcute/lexicons/syntax"; +import type { Cid, Nsid, ResourceUri } from "@atcute/lexicons/syntax"; import type { OAuthUserAgent } from "@atcute/oauth-browser-client"; import { awaitDeletedRecord, awaitIndexedRecord } from "$lib/api/awaitRecord"; import { serviceClient } from "$lib/api/_request"; @@ -95,6 +95,7 @@ export interface RepoLocation { knot: string; ownerDid: string; repoDid?: string; + cid?: Cid; } export const deleteRepo = async ( @@ -106,7 +107,7 @@ export const deleteRepo = async ( throw new Error("This repository predates repo DIDs and cannot be deleted here."); } const rkey = rkeyFromUri(repo.uri); - await deleteRecord(agent, REPO_COLLECTION, rkey); + await deleteRecord(agent, REPO_COLLECTION, rkey, repo.cid); try { await ok( serviceClient(agent, repo.knot).xrpc.call(deleteRepoSchema, { diff --git a/web/src/lib/components/settings/RepoGeneralForm.svelte b/web/src/lib/components/settings/RepoGeneralForm.svelte index 7ca45e86a..f951d91a1 100644 --- a/web/src/lib/components/settings/RepoGeneralForm.svelte +++ b/web/src/lib/components/settings/RepoGeneralForm.svelte @@ -124,7 +124,7 @@ const destroy = createAction(async () => { const agent = auth.agent; if (!agent) return; - await deleteRepo(agent, bobbinUrl, repo); + await deleteRepo(agent, bobbinUrl, { ...repo, cid: record.cid }); confirmDelete = false; await goto(resolve(`/${repo.ownerHandle}` as "/"), { invalidateAll: true }); }); -- 2.51.2