Refactor plugin management system
- Updated PluginLoader to utilize the new plugin marketplace manager for loading and managing plugins. - Simplified the plugin loading process by removing unnecessary state management and directly integrating with the plugin marketplace. - Enhanced error handling during plugin installation and uninstallation processes. - Removed legacy code related to Electron-specific plugin handling, streamlining the codebase for web compatibility. - Updated Plugins component to fetch marketplace plugins and installed plugins using the new plugin marketplace manager. - Refactored types related to plugins to import from the new plugin manager module, ensuring consistency and reducing redundancy. - Removed unused calling configuration from client settings and adjusted related types accordingly. - Cleaned up room state events by removing references to LiveKit service URLs, aligning with the updated architecture.
This commit is contained in:
@@ -2,7 +2,6 @@ import React, { ReactNode } from 'react';
|
||||
import { CallProvider, useCallService } from './useCall';
|
||||
import { CallOverlay } from './CallOverlay';
|
||||
import { IncomingCallNotification } from './IncomingCallNotification';
|
||||
import { useClientConfig } from '../../hooks/useClientConfig';
|
||||
|
||||
interface CallProviderWrapperProps {
|
||||
children: ReactNode;
|
||||
@@ -13,13 +12,7 @@ interface CallProviderWrapperProps {
|
||||
* Also renders the CallOverlay for active call controls and monitors incoming calls
|
||||
*/
|
||||
export function CallProviderWrapper({ children }: CallProviderWrapperProps) {
|
||||
const clientConfig = useClientConfig();
|
||||
const livekitServiceUrl = clientConfig.calling?.livekitServiceUrl;
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('CallProviderWrapper - config calling:', clientConfig.calling, 'livekitUrl:', livekitServiceUrl);
|
||||
|
||||
const callContextValue = useCallService({ livekitServiceUrl });
|
||||
const callContextValue = useCallService();
|
||||
|
||||
return (
|
||||
<CallProvider value={callContextValue}>
|
||||
|
||||
@@ -300,26 +300,10 @@ export class CallService {
|
||||
this.config.accessToken
|
||||
);
|
||||
|
||||
// Step 2: Determine LiveKit service URL (check room-level config first)
|
||||
let livekitServiceUrl = this.config.livekitServiceUrl;
|
||||
|
||||
// Check if room has a custom LiveKit config
|
||||
const room = this.matrixClient.getRoom(roomId);
|
||||
if (room) {
|
||||
const livekitConfigEvent = room.currentState.getStateEvents('im.paarrot.room.livekit_config', '');
|
||||
if (livekitConfigEvent) {
|
||||
const roomLivekitUrl = livekitConfigEvent.getContent()?.service_url;
|
||||
if (roomLivekitUrl) {
|
||||
console.log('Using room-level LiveKit URL:', roomLivekitUrl);
|
||||
livekitServiceUrl = roomLivekitUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Exchange OpenID token for LiveKit JWT
|
||||
// Step 2: Exchange OpenID token for LiveKit JWT
|
||||
console.log('Requesting LiveKit JWT for Matrix room:', roomId);
|
||||
this.livekitJwt = await fetchLiveKitJWT(
|
||||
livekitServiceUrl,
|
||||
this.config.livekitServiceUrl,
|
||||
roomId,
|
||||
this.config.userId,
|
||||
this.config.deviceId,
|
||||
|
||||
@@ -55,24 +55,17 @@ export function useCall(): CallContextValue {
|
||||
|
||||
export const CallProvider = CallContext.Provider;
|
||||
|
||||
interface UseCallServiceOptions {
|
||||
livekitServiceUrl?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to initialize and manage the call service
|
||||
* Should be used at the app level to provide call context
|
||||
* @param options - Optional configuration including livekitServiceUrl from client config
|
||||
*/
|
||||
export function useCallService(options?: UseCallServiceOptions): CallContextValue {
|
||||
export function useCallService(): CallContextValue {
|
||||
const mx = useMatrixClient();
|
||||
const [callService, setCallService] = useState<CallService | null>(null);
|
||||
const [activeCall, setActiveCall] = useState<ActiveCall | null>(null);
|
||||
const [callSupported, setCallSupported] = useState(false);
|
||||
const [callSupportLoading, setCallSupportLoading] = useState(true);
|
||||
|
||||
const configuredLivekitUrl = options?.livekitServiceUrl;
|
||||
|
||||
useEffect(() => {
|
||||
let unsubscribe: (() => void) | undefined;
|
||||
let service: CallService | undefined;
|
||||
@@ -89,30 +82,21 @@ export function useCallService(options?: UseCallServiceOptions): CallContextValu
|
||||
}
|
||||
|
||||
try {
|
||||
let livekitServiceUrl: string | undefined = configuredLivekitUrl;
|
||||
// Get LiveKit service URL from Matrix homeserver well-known
|
||||
const wellKnown = await fetchWellKnownWithRTC(baseUrl);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Call service init - well-known:', wellKnown);
|
||||
const livekitFocus = getLiveKitFocus(wellKnown);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Call service init - LiveKit focus:', livekitFocus);
|
||||
const livekitServiceUrl = livekitFocus?.livekit_service_url;
|
||||
|
||||
// If no configured URL, try to get from well-known
|
||||
if (!livekitServiceUrl) {
|
||||
const wellKnown = await fetchWellKnownWithRTC(baseUrl);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Call service init - well-known:', wellKnown);
|
||||
const livekitFocus = getLiveKitFocus(wellKnown);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Call service init - LiveKit focus:', livekitFocus);
|
||||
livekitServiceUrl = livekitFocus?.livekit_service_url;
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Call service init - Using configured LiveKit URL:', livekitServiceUrl);
|
||||
}
|
||||
|
||||
// If still no URL, log warning but allow service to initialize
|
||||
// Individual rooms may have their own LiveKit configs
|
||||
if (!livekitServiceUrl) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Call service init - No global LiveKit URL found');
|
||||
console.log('Call service init - Will check for room-level configs when joining calls');
|
||||
// Use a placeholder URL - room-level config will override this
|
||||
livekitServiceUrl = 'https://placeholder.invalid/livekit';
|
||||
console.log('Call service init - No LiveKit config in well-known, calls not supported');
|
||||
setCallSupported(false);
|
||||
setCallSupportLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
service = new CallService(
|
||||
|
||||
@@ -66,7 +66,7 @@ export async function requestOpenIdToken(
|
||||
|
||||
/**
|
||||
* Fetches a LiveKit JWT for joining a call using OpenID token authentication
|
||||
* @param livekitServiceUrl - The LiveKit service URL from well-known or config
|
||||
* @param livekitServiceUrl - The LiveKit service URL from Matrix homeserver well-known
|
||||
* @param roomId - The Matrix room ID to join
|
||||
* @param userId - The Matrix user ID
|
||||
* @param deviceId - The Matrix device ID
|
||||
|
||||
Reference in New Issue
Block a user