Live video on the AT Protocol

switch to AppBskyActorDefs.ProfileViewDetailed

+11 -8
+9 -6
js/components/src/context/profile-cache.tsx
··· 1 - import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs"; 2 import { 3 createContext, 4 useCallback, ··· 9 import { useUnauthenticatedBlueskyAppViewAgent } from "../streamplace-store"; 10 11 interface ProfileCacheContextValue { 12 - profiles: Record<string, ProfileViewDetailed>; 13 requestProfiles: (dids: string[]) => void; 14 } 15 ··· 22 children: React.ReactNode; 23 }) { 24 const agent = useUnauthenticatedBlueskyAppViewAgent(); 25 - const [profiles, setProfiles] = useState<Record<string, ProfileViewDetailed>>( 26 - {}, 27 - ); 28 const agentRef = useRef(agent); 29 agentRef.current = agent; 30 const profilesRef = useRef(profiles); ··· 54 agentRef.current 55 .getProfiles({ actors: toFetch }) 56 .then((result) => { 57 - const newProfiles: Record<string, ProfileViewDetailed> = {}; 58 result.data.profiles.forEach((p) => { 59 newProfiles[p.did] = p; 60 });
··· 1 + import { AppBskyActorDefs } from "@atproto/api"; 2 import { 3 createContext, 4 useCallback, ··· 9 import { useUnauthenticatedBlueskyAppViewAgent } from "../streamplace-store"; 10 11 interface ProfileCacheContextValue { 12 + profiles: Record<string, AppBskyActorDefs.ProfileViewDetailed>; 13 requestProfiles: (dids: string[]) => void; 14 } 15 ··· 22 children: React.ReactNode; 23 }) { 24 const agent = useUnauthenticatedBlueskyAppViewAgent(); 25 + const [profiles, setProfiles] = useState< 26 + Record<string, AppBskyActorDefs.ProfileViewDetailed> 27 + >({}); 28 const agentRef = useRef(agent); 29 agentRef.current = agent; 30 const profilesRef = useRef(profiles); ··· 54 agentRef.current 55 .getProfiles({ actors: toFetch }) 56 .then((result) => { 57 + const newProfiles: Record< 58 + string, 59 + AppBskyActorDefs.ProfileViewDetailed 60 + > = {}; 61 result.data.profiles.forEach((p) => { 62 newProfiles[p.did] = p; 63 });
+2 -2
js/components/src/hooks/useAvatars.tsx
··· 1 - import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs"; 2 import { useEffect, useMemo } from "react"; 3 import { useProfileCache } from "../context/profile-cache"; 4 5 export function useAvatars( 6 dids: string[], 7 - ): Record<string, ProfileViewDetailed> { 8 const { profiles, requestProfiles } = useProfileCache(); 9 10 useEffect(() => {
··· 1 + import { AppBskyActorDefs } from "@atproto/api"; 2 import { useEffect, useMemo } from "react"; 3 import { useProfileCache } from "../context/profile-cache"; 4 5 export function useAvatars( 6 dids: string[], 7 + ): Record<string, AppBskyActorDefs.ProfileViewDetailed> { 8 const { profiles, requestProfiles } = useProfileCache(); 9 10 useEffect(() => {