diff --git a/src/App.svelte b/src/App.svelte index 3ca9778..a8a0033 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -7,11 +7,13 @@
-

Welcome to the Feed

+
{#await accountsPromise}

Loading...

{:then accountsData}
+

ATProto PDS

+

Home to {accountsData.length} accounts

{#each accountsData as accountObject} {/each} @@ -29,7 +31,39 @@ {/each}
{/await} +
diff --git a/src/app.css b/src/app.css index 61ba367..2232051 100644 --- a/src/app.css +++ b/src/app.css @@ -1,16 +1,19 @@ -:root { - font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; +@font-face { + font-family: 'ProggyClean'; + src: url(https://witchcraft.systems/ProggyCleanNerdFont-Regular.ttf); +} - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; +::-webkit-scrollbar { + width: 0px; + background: transparent; +} - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; +* { + scrollbar-width: thin; + scrollbar-color: transparent transparent; + -ms-overflow-style: none; /* IE and Edge */ + -webkit-overflow-scrolling: touch; + -webkit-scrollbar: none; /* Safari */ } a { @@ -28,6 +31,11 @@ body { place-items: center; min-width: 320px; min-height: 100vh; + background-color: #12082b; + font-family: 'ProggyClean', monospace; + font-size: 24px; + color: white; + border-color: #8054f0; } h1 { @@ -35,45 +43,11 @@ h1 { line-height: 1.1; } -.card { - padding: 2em; -} - #app { - max-width: 1280px; + max-width: 1400px; margin: 0 auto; padding: 2rem; text-align: center; } -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/src/lib/AccountComponent.svelte b/src/lib/AccountComponent.svelte index 2ad7662..cee7fc7 100644 --- a/src/lib/AccountComponent.svelte +++ b/src/lib/AccountComponent.svelte @@ -1,23 +1,39 @@
{#if account.avatarCid} avatar of {account.displayName} {/if} -

{account.displayName}

+
{account.displayName || account.did}
diff --git a/src/lib/pdsfetch.ts b/src/lib/pdsfetch.ts index 885fcc5..748fee6 100644 --- a/src/lib/pdsfetch.ts +++ b/src/lib/pdsfetch.ts @@ -5,6 +5,7 @@ import type { AppBskyFeedPost, ComAtprotoRepoListRecords, } from "@atcute/client/lexicons"; +import { Config } from "../../config"; // import { ComAtprotoRepoListRecords.Record } from "@atcute/client/lexicons"; // import { AppBskyFeedPost } from "@atcute/client/lexicons"; // import { AppBskyActorDefs } from "@atcute/client/lexicons"; @@ -87,7 +88,7 @@ const didFromATuri = (aturi: string) => { const rpc = new XRPC({ handler: simpleFetchHandler({ - service: "https://pds.witchcraft.systems", + service: Config.PDS_URL, }), }); @@ -99,6 +100,7 @@ const getDidsFromPDS = async () => { }; const getAccountMetadata = async (did: `did:${string}:${string}`) => { // gonna assume self exists in the app.bsky.actor.profile + try { const { data } = await rpc.get("com.atproto.repo.getRecord", { params: { repo: did, @@ -116,6 +118,15 @@ const getAccountMetadata = async (did: `did:${string}:${string}`) => { account.avatarCid = value.avatar.ref["$link"]; } return account; + } + catch (e) { + console.error(`Error fetching metadata for ${did}:`, e); + return { + did: "error", + displayName: "", + avatarCid: null, + }; + } }; const getAllMetadataFromPds = async () => { @@ -125,21 +136,31 @@ const getAllMetadataFromPds = async () => { return await getAccountMetadata(repo); }), ); - return metadata; + return metadata.filter(account => account.did !== "error"); }; const fetchPosts = async (did: string) => { - const { data } = await rpc.get("com.atproto.repo.listRecords", { - params: { - repo: did, - collection: "app.bsky.feed.post", - limit: 5, - }, - }); - return { - records: data.records as ComAtprotoRepoListRecords.Record[], - did: did, - }; + try { + const { data } = await rpc.get("com.atproto.repo.listRecords", { + params: { + repo: did, + collection: "app.bsky.feed.post", + limit: 5, + }, + }); + return { + records: data.records as ComAtprotoRepoListRecords.Record[], + did: did, + error: false + }; + } catch (e) { + console.error(`Error fetching posts for ${did}:`, e); + return { + records: [], + did: did, + error: true + }; + } }; const fetchAllPosts = async () => { @@ -149,7 +170,8 @@ const fetchAllPosts = async () => { await fetchPosts(metadata.did) ), ); - const posts: Post[] = postRecords.flatMap((userFetch) => + const validPostRecords = postRecords.filter(record => !record.error); + const posts: Post[] = validPostRecords.flatMap((userFetch) => userFetch.records.map((record) => { const user = users.find((user: AccountMetadata) => user.did == userFetch.did