fix websocket refactor mess

This commit is contained in:
seavor 2026-04-16 15:37:59 -05:00
parent fea21b5057
commit 53639a8448
19 changed files with 179 additions and 209 deletions

View file

@ -0,0 +1,19 @@
import { createContext, useContext, useState, ReactNode } from 'react';
import { WebClient } from '@app/websocket';
import { createWebClientRequest, createWebClientResponse } from '@app/api';
const WebClientContext = createContext<WebClient | null>(null);
export function WebClientProvider({ children }: { children: ReactNode }) {
const [client] = useState(() => new WebClient(createWebClientRequest(), createWebClientResponse()));
return <WebClientContext value={client}>{children}</WebClientContext>;
}
export function useWebClient(): WebClient {
const client = useContext(WebClientContext);
if (!client) {
throw new Error('useWebClient must be used within a WebClientProvider');
}
return client;
}