feat: implement Paarrot API for Electron integration with navigation and IPC handlers
This commit is contained in:
@@ -19,6 +19,28 @@ interface CallContextValue {
|
||||
|
||||
const CallContext = createContext<CallContextValue | null>(null);
|
||||
|
||||
/**
|
||||
* Global reference to CallService for use outside React components
|
||||
* (e.g., from Electron IPC handlers)
|
||||
*/
|
||||
let globalCallServiceInstance: CallService | null = null;
|
||||
|
||||
/**
|
||||
* Get the global CallService instance
|
||||
* @returns The CallService instance or null if not initialized
|
||||
*/
|
||||
export function getCallService(): CallService | null {
|
||||
return globalCallServiceInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the global CallService instance
|
||||
* @param service - The CallService instance
|
||||
*/
|
||||
function setGlobalCallService(service: CallService | null): void {
|
||||
globalCallServiceInstance = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to access the call context
|
||||
* @returns The call context value
|
||||
@@ -103,6 +125,7 @@ export function useCallService(options?: UseCallServiceOptions): CallContextValu
|
||||
);
|
||||
|
||||
setCallService(service);
|
||||
setGlobalCallService(service); // Make available globally for Paarrot API
|
||||
setCallSupported(true);
|
||||
setCallSupportLoading(false);
|
||||
// eslint-disable-next-line no-console
|
||||
@@ -146,6 +169,7 @@ export function useCallService(options?: UseCallServiceOptions): CallContextValu
|
||||
return () => {
|
||||
unsubscribe?.();
|
||||
service?.dispose();
|
||||
setGlobalCallService(null); // Clear global reference
|
||||
};
|
||||
}, [mx, configuredLivekitUrl]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user