this repo has no description
0
fork

Configure Feed

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

error handling for invalid usernames

alice 5b1f342c 8c93a698

+10 -5
+9 -2
src/App.tsx
··· 25 25 26 26 const [isLoading, setIsLoading] = useState<boolean>(false); 27 27 const loadPosts = useCallback(async () => { 28 - setIsLoading(true); 29 28 try { 30 - const data = await getData(agent!, heatmapSubject); 29 + let actor: any; 30 + try { 31 + actor = (await agent.getProfile({ actor: heatmapSubject.trim().replace('@', '') })).data.did; 32 + } catch (e) { 33 + alert('Invalid username!'); 34 + return; 35 + } 36 + setIsLoading(true); 37 + const data = await getData(agent!, actor); 31 38 setData(data); 32 39 } finally { 33 40 setIsLoading(false);
+1 -3
src/atproto.tsx
··· 2 2 import { getUserCreatedAt, paginateAll } from './helpers.tsx'; 3 3 4 4 export const getData = async (agent: bsky.BskyAgent, actor: string) => { 5 - actor = (await agent.getProfile({ actor: actor.trim().replace('@', '') })).data.did; 6 - 7 5 // source: https://github.com/bluesky-social/atproto/blob/efb1cac2bfc8ccb77c0f4910ad9f3de7370fbebb/packages/bsky/tests/views/author-feed.test.ts#L94 8 6 const paginator = async (cursor?: string) => { 9 7 const res = await agent.getAuthorFeed({ 10 - actor: actor, 8 + actor, 11 9 cursor, 12 10 limit: 100, 13 11 });