tangled
alpha
login
or
join now
stream.place
/
streamplace
74
fork
atom
Live video on the AT Protocol
74
fork
atom
overview
issues
1
pulls
pipelines
switch to AppBskyActorDefs.ProfileViewDetailed
Natalie B.
1 week ago
50a8de08
cb0fd313
+11
-8
2 changed files
expand all
collapse all
unified
split
js
components
src
context
profile-cache.tsx
hooks
useAvatars.tsx
+9
-6
js/components/src/context/profile-cache.tsx
···
1
1
-
import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs";
1
1
+
import { AppBskyActorDefs } from "@atproto/api";
2
2
import {
3
3
createContext,
4
4
useCallback,
···
9
9
import { useUnauthenticatedBlueskyAppViewAgent } from "../streamplace-store";
10
10
11
11
interface ProfileCacheContextValue {
12
12
-
profiles: Record<string, ProfileViewDetailed>;
12
12
+
profiles: Record<string, AppBskyActorDefs.ProfileViewDetailed>;
13
13
requestProfiles: (dids: string[]) => void;
14
14
}
15
15
···
22
22
children: React.ReactNode;
23
23
}) {
24
24
const agent = useUnauthenticatedBlueskyAppViewAgent();
25
25
-
const [profiles, setProfiles] = useState<Record<string, ProfileViewDetailed>>(
26
26
-
{},
27
27
-
);
25
25
+
const [profiles, setProfiles] = useState<
26
26
+
Record<string, AppBskyActorDefs.ProfileViewDetailed>
27
27
+
>({});
28
28
const agentRef = useRef(agent);
29
29
agentRef.current = agent;
30
30
const profilesRef = useRef(profiles);
···
54
54
agentRef.current
55
55
.getProfiles({ actors: toFetch })
56
56
.then((result) => {
57
57
-
const newProfiles: Record<string, ProfileViewDetailed> = {};
57
57
+
const newProfiles: Record<
58
58
+
string,
59
59
+
AppBskyActorDefs.ProfileViewDetailed
60
60
+
> = {};
58
61
result.data.profiles.forEach((p) => {
59
62
newProfiles[p.did] = p;
60
63
});
+2
-2
js/components/src/hooks/useAvatars.tsx
···
1
1
-
import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs";
1
1
+
import { AppBskyActorDefs } from "@atproto/api";
2
2
import { useEffect, useMemo } from "react";
3
3
import { useProfileCache } from "../context/profile-cache";
4
4
5
5
export function useAvatars(
6
6
dids: string[],
7
7
-
): Record<string, ProfileViewDetailed> {
7
7
+
): Record<string, AppBskyActorDefs.ProfileViewDetailed> {
8
8
const { profiles, requestProfiles } = useProfileCache();
9
9
10
10
useEffect(() => {