Files
cinny/src/app/hooks/useClientConfig.ts
Max Litruv Boonzaayer 94f8466d1c feat: add call management features with useCall and useRoomCallMembers hooks
- Implemented useCall hook for managing call state and actions.
- Created useRoomCallMembers hook to track active call members in a room.
- Added useRtcConfig for fetching RTC configurations and LiveKit JWT.
- Developed Audio settings component for managing audio devices and settings.
- Introduced device selection and screen sharing options in the Audio settings.
- Persisted audio settings in localStorage for user preferences.
2026-01-23 19:35:25 +11:00

49 lines
1.2 KiB
TypeScript

import { createContext, useContext } from 'react';
export type HashRouterConfig = {
enabled?: boolean;
basename?: string;
};
export type CallingConfig = {
livekitServiceUrl?: string;
};
export type ClientConfig = {
defaultHomeserver?: number;
homeserverList?: string[];
allowCustomHomeservers?: boolean;
featuredCommunities?: {
openAsDefault?: boolean;
spaces?: string[];
rooms?: string[];
servers?: string[];
};
calling?: CallingConfig;
hashRouter?: HashRouterConfig;
};
const ClientConfigContext = createContext<ClientConfig | null>(null);
export const ClientConfigProvider = ClientConfigContext.Provider;
export function useClientConfig(): ClientConfig {
const config = useContext(ClientConfigContext);
if (!config) throw new Error('Client config are not provided!');
return config;
}
export const clientDefaultServer = (clientConfig: ClientConfig): string =>
clientConfig.homeserverList?.[clientConfig.defaultHomeserver ?? 0] ?? 'matrix.org';
export const clientAllowedServer = (clientConfig: ClientConfig, server: string): boolean => {
const { homeserverList, allowCustomHomeservers } = clientConfig;
if (allowCustomHomeservers) return true;
return homeserverList?.includes(server) === true;
};