forked from pdsls.dev/pdsls
atproto explorer

replace placeholder with current record

juli.ee 8b7e45a8 47dfd578

verified
Changed files
+14 -5
src
components
views
+10 -2
src/components/create.tsx
··· 10 10 import { TextInput } from "./text-input.jsx"; 11 11 import Tooltip from "./tooltip.jsx"; 12 12 13 + export const [placeholder, setPlaceholder] = createSignal<any>(); 14 + 13 15 export const RecordEditor = (props: { create: boolean; record?: any; refetch?: any }) => { 14 16 const navigate = useNavigate(); 15 17 const params = useParams(); ··· 19 21 let blobInput!: HTMLInputElement; 20 22 let formRef!: HTMLFormElement; 21 23 22 - const placeholder = () => { 24 + const defaultPlaceholder = () => { 23 25 return { 24 26 $type: "app.bsky.feed.post", 25 27 text: "This post was sent from PDSls", ··· 284 286 </div> 285 287 </div> 286 288 <Editor 287 - content={JSON.stringify(props.create ? placeholder() : props.record, null, 2)} 289 + content={JSON.stringify( 290 + !props.create ? props.record 291 + : params.rkey ? placeholder() 292 + : defaultPlaceholder(), 293 + null, 294 + 2, 295 + )} 288 296 /> 289 297 <div class="flex flex-col gap-2"> 290 298 <Show when={notice()}>
+4 -3
src/views/record.tsx
··· 5 5 import { createResource, createSignal, ErrorBoundary, Show, Suspense } from "solid-js"; 6 6 import { Backlinks } from "../components/backlinks.jsx"; 7 7 import { Button } from "../components/button.jsx"; 8 - import { RecordEditor } from "../components/create.jsx"; 8 + import { RecordEditor, setPlaceholder } from "../components/create.jsx"; 9 9 import { CopyMenu, DropdownMenu, MenuProvider, NavMenu } from "../components/dropdown.jsx"; 10 10 import { JSONValue } from "../components/json.jsx"; 11 11 import { agent } from "../components/login.jsx"; ··· 51 51 setNotice(res.data.error); 52 52 throw new Error(res.data.error); 53 53 } 54 + setPlaceholder(res.data.value); 54 55 setExternalLink(checkUri(res.data.uri, res.data.value)); 55 56 resolveLexicon(params.collection as Nsid); 56 57 verify(res.data); ··· 58 59 return res.data; 59 60 }; 60 61 62 + const [record, { refetch }] = createResource(fetchRecord); 63 + 61 64 const verify = async (record: { 62 65 uri: ResourceUri; 63 66 value: Record<string, unknown>; ··· 101 104 setLexiconUri(`at://${res}/com.atproto.lexicon.schema/${nsid}`); 102 105 } catch {} 103 106 }; 104 - 105 - const [record, { refetch }] = createResource(fetchRecord); 106 107 107 108 const deleteRecord = async () => { 108 109 rpc = new Client({ handler: agent()! });