Files
orca/mobile/src/components/host-protocol-gates-context.ts
Neil 19043a3d76 refactor(mobile): organize pairing, session, RPC and host owners (#39846)
* refactor(mobile): give relay and encryption concrete owners

* refactor(mobile): organize session and review feature owners

* refactor(mobile): organize RPC and host ownership

* test(mobile): point render fixtures at concrete owners

* refactor(mobile): use explicit type-only owner imports
2026-11-08 07:19:05 -08:00

20 lines
811 B
TypeScript

import { createContext, useContext } from 'react'
import type { HostStatusGates } from '../transport/connection/host-status-gates'
// Apart from the gate screen so a workspace's client can read capabilities without its UI.
export const HostStatusGatesContext = createContext<HostStatusGates | null>(null)
/** The gates, or null outside a host route (a screen mounted on its own, as the recorder does). */
export function useOptionalHostProtocolGates(): HostStatusGates | null {
return useContext(HostStatusGatesContext)
}
/** The gates of the host route this screen sits under. */
export function useHostProtocolGates(): HostStatusGates {
const gates = useOptionalHostProtocolGates()
if (!gates) {
throw new Error('useHostProtocolGates must be used inside <HostProtocolGate>')
}
return gates
}