This commit is contained in:
Timo K
2025-11-14 16:17:55 +01:00
parent 9e65ca249c
commit 94782459e6
3 changed files with 24 additions and 43 deletions

View File

@@ -137,7 +137,7 @@ export const createLocalMembership$ = ({
matrixRoom, matrixRoom,
trackProcessorState$, trackProcessorState$,
widget, widget,
logger, logger: parentLogger,
}: Props): { }: Props): {
// publisher: Publisher // publisher: Publisher
requestConnect: () => LocalMemberConnectionState; requestConnect: () => LocalMemberConnectionState;
@@ -163,8 +163,8 @@ export const createLocalMembership$ = ({
/** @deprecated use state instead*/ /** @deprecated use state instead*/
configError$: Behavior<ElementCallError | null>; configError$: Behavior<ElementCallError | null>;
} => { } => {
const prefixLogger = logger.getChild("[LocalMembership]"); const logger = parentLogger.getChild("[LocalMembership]");
prefixLogger.debug(`Creating local membership..`); logger.debug(`Creating local membership..`);
const state = { const state = {
livekit$: new BehaviorSubject<LocalMemberLivekitState>({ livekit$: new BehaviorSubject<LocalMemberLivekitState>({
state: LivekitState.Uninitialized, state: LivekitState.Uninitialized,
@@ -187,35 +187,23 @@ export const createLocalMembership$ = ({
// Drop Epoch data here since we will not combine this anymore // Drop Epoch data here since we will not combine this anymore
const localConnection$ = scope.behavior( const localConnection$ = scope.behavior(
combineLatest([connectionManager.connections$, localTransport$]) combineLatest([connectionManager.connections$, localTransport$]).pipe(
.pipe( map(([connections, localTransport]) => {
map(([connections, localTransport]) => { if (localTransport === null) {
if (localTransport === null) { return null;
return null; }
} return (
return ( connections.value.find((connection) =>
connections.value.find((connection) => areLivekitTransportsEqual(connection.transport, localTransport),
areLivekitTransportsEqual(connection.transport, localTransport), ) ?? null
) ?? null );
); }),
}), tap((connection) => {
) logger.info(
.pipe( `Local connection updated: ${connection?.transport?.livekit_service_url}`,
distinctUntilChanged((a, b) => { );
const eq = a === b; }),
logger.debug( ),
`distinctUntilChanged: Local connection equality check: ${eq}`,
);
return eq;
}),
)
.pipe(
tap((connection) => {
prefixLogger.info(
`Local connection updated: ${connection?.transport?.livekit_service_url}`,
);
}),
),
); );
/** /**
* Whether we are connected to the MatrixRTC session. * Whether we are connected to the MatrixRTC session.
@@ -247,7 +235,7 @@ export const createLocalMembership$ = ({
), ),
).pipe( ).pipe(
tap((connected) => { tap((connected) => {
prefixLogger.info(`Homeserver connected update: ${connected}`); logger.info(`Homeserver connected update: ${connected}`);
}), }),
), ),
); );
@@ -563,6 +551,7 @@ interface EnterRTCSessionOptions {
* @param rtcSession * @param rtcSession
* @param transport * @param transport
* @param options * @param options
* @throws If the widget could not send ElementWidgetActions.JoinCall action.
*/ */
async function enterRTCSession( async function enterRTCSession(
rtcSession: MatrixRTCSession, rtcSession: MatrixRTCSession,
@@ -607,11 +596,6 @@ async function enterRTCSession(
}, },
); );
if (widget) { if (widget) {
// try {
await widget.api.transport.send(ElementWidgetActions.JoinCall, {}); await widget.api.transport.send(ElementWidgetActions.JoinCall, {});
// TODO Why catch and swallow?
// } catch (e) {
// logger.error("Failed to send join action", e);
// }
} }
} }

View File

@@ -68,9 +68,6 @@ function setupTest(): void {
}), }),
getDeviceId: vi.fn().mockReturnValue("ABCDEF"), getDeviceId: vi.fn().mockReturnValue("ABCDEF"),
} as unknown as OpenIDClientParts); } as unknown as OpenIDClientParts);
// fakeMembershipsFocusMap$ = new BehaviorSubject<
// { membership: CallMembership; transport: LivekitTransport }[]
// >([]);
localParticipantEventEmiter = new EventEmitter(); localParticipantEventEmiter = new EventEmitter();

View File

@@ -117,9 +117,9 @@ export function createConnectionManager$({
scope, scope,
connectionFactory, connectionFactory,
inputTransports$, inputTransports$,
logger: _logger, logger: parentLogger,
}: Props): IConnectionManager { }: Props): IConnectionManager {
const logger = _logger.getChild("[ConnectionManager]"); const logger = parentLogger.getChild("[ConnectionManager]");
const running$ = new BehaviorSubject(true); const running$ = new BehaviorSubject(true);
scope.onEnd(() => running$.next(false)); scope.onEnd(() => running$.next(false));