From dfda14be3c4a4712dfd98b296791780b9f2d07d3 Mon Sep 17 00:00:00 2001 From: Juliet Date: Fri, 5 Dec 2025 21:38:29 +0100 Subject: [PATCH] fallback when describeRepo fails --- src/views/repo.tsx | 60 ++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/views/repo.tsx b/src/views/repo.tsx index 7f5ca5c..0873c77 100644 --- a/src/views/repo.tsx +++ b/src/views/repo.tsx @@ -140,37 +140,41 @@ export const RepoView = () => { } rpc = new Client({ handler: new CredentialManager({ service: pds }) }); - const res = await rpc.get("com.atproto.repo.describeRepo", { - params: { repo: did as ActorIdentifier }, - }); - if (res.ok) { - const collections: Record = {}; - res.data.collections.forEach((c) => { - const nsid = c.split("."); - if (nsid.length > 2) { - const authority = `${nsid[0]}.${nsid[1]}`; - collections[authority] = { - nsids: (collections[authority]?.nsids ?? []).concat(nsid.slice(2).join(".")), - hidden: false, - }; - } + try { + const res = await rpc.get("com.atproto.repo.describeRepo", { + params: { repo: did as ActorIdentifier }, }); - setNsids(collections); - } else { - console.error(res.data.error); - switch (res.data.error) { - case "RepoDeactivated": - setError("Deactivated"); - break; - case "RepoTakendown": - setError("Takendown"); - break; - default: - setError("Unreachable"); + if (res.ok) { + const collections: Record = {}; + res.data.collections.forEach((c) => { + const nsid = c.split("."); + if (nsid.length > 2) { + const authority = `${nsid[0]}.${nsid[1]}`; + collections[authority] = { + nsids: (collections[authority]?.nsids ?? []).concat(nsid.slice(2).join(".")), + hidden: false, + }; + } + }); + setNsids(collections); + } else { + console.error(res.data.error); + switch (res.data.error) { + case "RepoDeactivated": + setError("Deactivated"); + break; + case "RepoTakendown": + setError("Takendown"); + break; + default: + setError("Unreachable"); + } } - } - return res.data; + return res.data; + } catch { + return {}; + } }; const [repo] = createResource(fetchRepo); -- 2.51.2