···6262}
63636464// If you want to start measuring performance in your app, pass a function
6565-// to log results (for example: reportWebVitals(console.log))
6565+// to log results (for example: reportWebVitals(// /*mass comment*/ console.log))
6666// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
6767reportWebVitals();
···7788// This assumes your client-metadata.json is in the /public folder
99// and will be served at the root of your domain.
1010-import clientMetadata from '../../public/client-metadata.json' assert { type: 'json' };
1010+import clientMetadata from '../../public/client-metadata.json' with { type: 'json' };
11111212export const oauthClient = new BrowserOAuthClient({
1313 // The type assertion is needed because the static import isn't strictly typed
+4-5
src/utils/useHydrated.ts
···11-import { useState, useEffect, useMemo } from "react";
21import {
22+ type $Typed,
33+ AppBskyActorDefs,
34 AppBskyEmbedExternal,
45 AppBskyEmbedImages,
56 AppBskyEmbedRecord,
67 AppBskyEmbedRecordWithMedia,
78 AppBskyEmbedVideo,
88- AppBskyActorDefs,
99 AppBskyFeedPost,
1010 AtUri,
1111- type $Typed,
1211} from "@atproto/api";
1313-import * as ATPAPI from "@atproto/api"
1212+import { useEffect, useMemo,useState } from "react";
14131515-import { useQueryPost, useQueryProfile, useQueryIdentity } from "./useQuery";
1414+import { useQueryIdentity,useQueryPost, useQueryProfile } from "./useQuery";
16151716type QueryResultData<T extends (...args: any) => any> = ReturnType<T> extends
1817 | { data: infer D }
+65-14
src/utils/useQuery.ts
···11+import * as ATPAPI from "@atproto/api";
12import {
33+ type QueryFunctionContext,
24 queryOptions,
33- useQuery,
45 useInfiniteQuery,
55- type QueryFunctionContext,
66- type UseQueryResult,
77- type InfiniteData
88-} from "@tanstack/react-query";
99-import * as ATPAPI from "@atproto/api";
66+ useQuery,
77+ type UseQueryResult} from "@tanstack/react-query";
108119export function constructIdentityQuery(didorhandle?: string) {
1210 return queryOptions({
···2826 return undefined;
2927 }
3028 },
2929+ staleTime: /*0,//*/ 5 * 60 * 1000, // 5 minutes
3030+ gcTime: /*0//*/5 * 60 * 1000,
3131 });
3232}
3333export function useQueryIdentity(didorhandle: string): UseQueryResult<
···6565 const res = await fetch(
6666 `https://slingshot.microcosm.blue/xrpc/com.bad-example.repo.getUriRecord?at_uri=${encodeURIComponent(uri)}`
6767 );
6868- if (!res.ok) throw new Error("Failed to fetch post");
6868+ let data: any;
6969+ try {
7070+ data = await res.json();
7171+ } catch {
7272+ return undefined;
7373+ }
7474+ if (res.status === 400) return undefined;
7575+ if (data?.error === "InvalidRequest" && data.message?.includes("Could not find repo")) {
7676+ return undefined; // cache “not found”
7777+ }
6978 try {
7070- return (await res.json()) as {
7979+ if (!res.ok) throw new Error("Failed to fetch post");
8080+ return (data) as {
7181 uri: string;
7282 cid: string;
7373- value: ATPAPI.AppBskyFeedPost.Record;
8383+ value: any;
7484 };
7585 } catch (_e) {
7686 return undefined;
7787 }
7888 },
8989+ retry: (failureCount, error) => {
9090+ // dont retry 400 errors
9191+ if ((error as any)?.message?.includes("400")) return false;
9292+ return failureCount < 2;
9393+ },
9494+ staleTime: /*0,//*/ 5 * 60 * 1000, // 5 minutes
9595+ gcTime: /*0//*/5 * 60 * 1000,
7996 });
8097}
8198export function useQueryPost(uri: string): UseQueryResult<
···111128 const res = await fetch(
112129 `https://slingshot.microcosm.blue/xrpc/com.bad-example.repo.getUriRecord?at_uri=${encodeURIComponent(uri)}`
113130 );
114114- if (!res.ok) throw new Error("Failed to fetch post");
131131+ let data: any;
115132 try {
116116- return (await res.json()) as {
133133+ data = await res.json();
134134+ } catch {
135135+ return undefined;
136136+ }
137137+ if (res.status === 400) return undefined;
138138+ if (data?.error === "InvalidRequest" && data.message?.includes("Could not find repo")) {
139139+ return undefined; // cache “not found”
140140+ }
141141+ try {
142142+ if (!res.ok) throw new Error("Failed to fetch post");
143143+ return (data) as {
117144 uri: string;
118145 cid: string;
119119- value: ATPAPI.AppBskyActorProfile.Record;
146146+ value: any;
120147 };
121148 } catch (_e) {
122149 return undefined;
123150 }
124151 },
152152+ retry: (failureCount, error) => {
153153+ // dont retry 400 errors
154154+ if ((error as any)?.message?.includes("400")) return false;
155155+ return failureCount < 2;
156156+ },
157157+ staleTime: /*0,//*/ 5 * 60 * 1000, // 5 minutes
158158+ gcTime: /*0//*/5 * 60 * 1000,
125159 });
126160}
127161export function useQueryProfile(uri: string): UseQueryResult<
···418452 const res = await fetch(
419453 `https://slingshot.microcosm.blue/xrpc/com.bad-example.repo.getUriRecord?at_uri=${encodeURIComponent(uri)}`
420454 );
421421- if (!res.ok) throw new Error("Failed to fetch post");
455455+ let data: any;
456456+ try {
457457+ data = await res.json();
458458+ } catch {
459459+ return undefined;
460460+ }
461461+ if (res.status === 400) return undefined;
462462+ if (data?.error === "InvalidRequest" && data.message?.includes("Could not find repo")) {
463463+ return undefined; // cache “not found”
464464+ }
422465 try {
423423- return (await res.json()) as {
466466+ if (!res.ok) throw new Error("Failed to fetch post");
467467+ return (data) as {
424468 uri: string;
425469 cid: string;
426470 value: any;
···429473 return undefined;
430474 }
431475 },
476476+ retry: (failureCount, error) => {
477477+ // dont retry 400 errors
478478+ if ((error as any)?.message?.includes("400")) return false;
479479+ return failureCount < 2;
480480+ },
481481+ staleTime: /*0,//*/ 5 * 60 * 1000, // 5 minutes
482482+ gcTime: /*0//*/5 * 60 * 1000,
432483 });
433484}
434485export function useQueryArbitrary(uri: string): UseQueryResult<