Live video on the AT Protocol
1import { useMemo } from "react";
2import { StreamplaceAgent } from "streamplace";
3import { useStreamplaceStore } from ".";
4
5export function usePDSAgent(): StreamplaceAgent | null {
6 const oauthSession = useStreamplaceStore((state) => state.oauthSession);
7 // oauthsession is
8 // - undefined when loading
9 // - null when logged out, and
10 // - SessionManager when logged in
11 return useMemo(() => {
12 if (!oauthSession) {
13 if (oauthSession === undefined) return null;
14 // TODO: change once we allow unauthed requests + profile indexing
15 // it's bluesky's AppView b/c otherwise we'd have goosewithpipe.jpg
16 // showing up everywhere
17 return new StreamplaceAgent("https://public.api.bsky.app"); // nodeUrl);
18 }
19
20 return new StreamplaceAgent(oauthSession);
21 }, [oauthSession]);
22}