atproto explorer
0
fork

Configure Feed

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

redirect when handle in url

Juliet da705be9 dc576ed3

+16 -18
+8 -2
src/layout.tsx
··· 6 6 import { NavBar } from "./components/navbar.jsx"; 7 7 import { Search } from "./components/search.jsx"; 8 8 import { AccountManager } from "./components/account.jsx"; 9 + import { resolveHandle } from "./utils/api.js"; 9 10 10 11 export const [theme, setTheme] = createSignal( 11 12 ( ··· 28 29 console.error(err); 29 30 } 30 31 const params = useParams(); 32 + const location = useLocation(); 31 33 onMount(async () => { 34 + if (params.repo && !params.repo.startsWith("did:")) { 35 + const did = await resolveHandle(params.repo); 36 + window.location.href = location.pathname.replace(params.repo, did); 37 + } 32 38 await retrieveSession(); 33 39 if (loginState() && location.pathname === "/") 34 40 window.location.href = `/at/${agent.sub}`; ··· 81 87 </div> 82 88 </div> 83 89 <div class="mb-5 flex max-w-full flex-col items-center text-pretty md:max-w-screen-md"> 84 - <Show when={useLocation().pathname !== "/login"}> 90 + <Show when={location.pathname !== "/login"}> 85 91 <Search /> 86 92 </Show> 87 93 <Show when={params.pds}> 88 94 <NavBar params={params} /> 89 95 </Show> 90 - <Show keyed when={useLocation().pathname}> 96 + <Show keyed when={location.pathname}> 91 97 <ErrorBoundary 92 98 fallback={(err) => ( 93 99 <div class="mt-3 break-words">Error: {err.message}</div>
+2 -3
src/views/blob.tsx
··· 1 1 import { createResource, createSignal, For, Show } from "solid-js"; 2 2 import { CredentialManager, XRPC } from "@atcute/client"; 3 3 import { query, useParams } from "@solidjs/router"; 4 - import { resolveHandle, resolvePDS } from "../utils/api.js"; 4 + import { resolvePDS } from "../utils/api.js"; 5 5 6 6 const BlobView = () => { 7 7 const params = useParams(); 8 8 const [cursor, setCursor] = createSignal<string>(); 9 - let did = params.repo; 9 + const did = params.repo; 10 10 let pds: string; 11 11 let rpc: XRPC; 12 12 ··· 23 23 ); 24 24 25 25 const fetchBlobs = async (): Promise<string[]> => { 26 - if (!did.startsWith("did:")) did = await resolveHandle(params.repo); 27 26 if (!pds) pds = await resolvePDS(did); 28 27 if (!rpc) 29 28 rpc = new XRPC({ handler: new CredentialManager({ service: pds }) });
+2 -3
src/views/collection.tsx
··· 15 15 ComAtprotoRepoListRecords, 16 16 } from "@atcute/client/lexicons"; 17 17 import { A, action, query, useParams } from "@solidjs/router"; 18 - import { resolveHandle, resolvePDS } from "../utils/api.js"; 18 + import { resolvePDS } from "../utils/api.js"; 19 19 import * as TID from "@atcute/tid"; 20 20 import { JSONType, JSONValue } from "../components/json.jsx"; 21 21 import { agent, loginState } from "../components/login.jsx"; ··· 89 89 const [lastSelected, setLastSelected] = createSignal<number>(); 90 90 const [modal, setModal] = createSignal<HTMLDialogElement>(); 91 91 const [openDelete, setOpenDelete] = createSignal(false); 92 - let did = params.repo; 92 + const did = params.repo; 93 93 let pds: string; 94 94 let rpc: XRPC; 95 95 ··· 124 124 ); 125 125 126 126 const fetchRecords = async () => { 127 - if (!did.startsWith("did:")) did = await resolveHandle(params.repo); 128 127 if (!pds) pds = await resolvePDS(did); 129 128 if (!rpc) 130 129 rpc = new XRPC({ handler: new CredentialManager({ service: pds }) });
+2 -5
src/views/record.tsx
··· 8 8 import { Editor } from "../components/editor.jsx"; 9 9 import { editor } from "monaco-editor"; 10 10 import { setCID, setValidRecord, validRecord } from "../components/navbar.jsx"; 11 - import { didDocCache, resolveHandle, resolvePDS } from "../utils/api.js"; 11 + import { didDocCache, resolvePDS } from "../utils/api.js"; 12 12 import { theme } from "../layout.jsx"; 13 13 14 14 const RecordView = () => { ··· 41 41 window.addEventListener("keydown", keyEvent); 42 42 setCID(undefined); 43 43 setValidRecord(undefined); 44 - const did = 45 - params.repo.startsWith("did:") ? 46 - params.repo 47 - : await resolveHandle(params.repo); 44 + const did = params.repo; 48 45 const pds = await resolvePDS(did); 49 46 rpc = new XRPC({ handler: new CredentialManager({ service: pds }) }); 50 47 try {
+2 -5
src/views/repo.tsx
··· 1 1 import { createSignal, For, Show, createResource } from "solid-js"; 2 2 import { CredentialManager, XRPC } from "@atcute/client"; 3 3 import { A, query, useParams } from "@solidjs/router"; 4 - import { didDocCache, resolveHandle, resolvePDS } from "../utils/api.js"; 4 + import { didDocCache, resolvePDS } from "../utils/api.js"; 5 5 import { DidDocument } from "@atcute/client/utils/did"; 6 6 7 7 const RepoView = () => { ··· 16 16 ); 17 17 18 18 const fetchRepo = async () => { 19 - const did = 20 - params.repo.startsWith("did:") ? 21 - params.repo 22 - : await resolveHandle(params.repo); 19 + const did = params.repo; 23 20 const pds = await resolvePDS(did); 24 21 rpc = new XRPC({ handler: new CredentialManager({ service: pds }) }); 25 22 const res = await describeRepo(did);