mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* 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
20 lines
811 B
TypeScript
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
|
|
}
|