Open History to see the last commit
1import { createPeerLinkEnvironmentAtoms } from "@t3tools/client-runtime/state/peerLinks";
2import { AuthAccessReadScope } from "@t3tools/contracts";
3
4import { connectionAtomRuntime } from "../connection/runtime";
5import { useEnvironments } from "./environments";
6import { useEnvironmentsWithScope } from "./session";
7
8export const peerLinkEnvironment = createPeerLinkEnvironmentAtoms(connectionAtomRuntime);
9
10export function usePeerLinkHosts() {
11 const { environments } = useEnvironments();
12 const supported = environments.filter(
13 (environment) =>
14 environment.connection.phase === "connected" &&
15 environment.serverConfig?.environment.capabilities.peerLinks === true,
16 );
17 const readable = useEnvironmentsWithScope(supported, AuthAccessReadScope);
18 return supported.filter((environment) => readable.has(environment.environmentId));
19}