fix playwright test! (It caught an actual bug!!! so the right wording

would be: fix implementation thanks to the playwright test!
This commit is contained in:
Timo K
2025-12-01 17:29:21 +01:00
parent f26aa8f970
commit 63cd4f79dd
3 changed files with 21 additions and 10 deletions

View File

@@ -584,7 +584,6 @@ export function createCallViewModel$(
// in a split-brained state.
// DISCUSSION own membership manager ALSO this probably can be simplifis
const reconnecting$ = localMembership.reconnecting$;
const pretendToBeDisconnected$ = reconnecting$;
const audioParticipants$ = scope.behavior(
matrixLivekitMembers$.pipe(
@@ -633,7 +632,7 @@ export function createCallViewModel$(
);
const handsRaised$ = scope.behavior(
handsRaisedSubject$.pipe(pauseWhen(pretendToBeDisconnected$)),
handsRaisedSubject$.pipe(pauseWhen(reconnecting$)),
);
const reactions$ = scope.behavior(
@@ -646,7 +645,7 @@ export function createCallViewModel$(
]),
),
),
pauseWhen(pretendToBeDisconnected$),
pauseWhen(reconnecting$),
),
);
@@ -737,7 +736,7 @@ export function createCallViewModel$(
livekitRoom$,
focusUrl$,
mediaDevices,
pretendToBeDisconnected$,
reconnecting$,
displayName$,
matrixMemberMetadataStore.createAvatarUrlBehavior$(userId),
handsRaised$.pipe(map((v) => v[participantId]?.time ?? null)),

View File

@@ -234,19 +234,26 @@ export const createLocalMembership$ = ({
// */
const connected$ = scope.behavior(
and$(
homeserverConnected$,
homeserverConnected$.pipe(
tap((v) => logger.info("matrix: Connected state changed", v)),
),
localConnectionState$.pipe(
switchMap((state) => {
logger.info("livekit: Connected state changed", state);
if (!state) return of(false);
if (state.state === "ConnectedToLkRoom") {
state.livekitConnectionState$.pipe(
logger.info(
"livekit: Connected state changed (inner livekitConnectionState$)",
state.livekitConnectionState$.value,
);
return state.livekitConnectionState$.pipe(
map((lkState) => lkState === ConnectionState.Connected),
);
}
return of(false);
}),
),
),
).pipe(tap((v) => logger.info("combined: Connected state changed", v))),
);
// MATRIX RELATED

View File

@@ -19,7 +19,7 @@ import {
RoomEvent,
} from "livekit-client";
import { type LivekitTransport } from "matrix-js-sdk/lib/matrixrtc";
import { BehaviorSubject, map, type Observable } from "rxjs";
import { BehaviorSubject, map } from "rxjs";
import { type Logger } from "matrix-js-sdk/lib/logger";
import {
@@ -54,7 +54,7 @@ export type ConnectionState =
| { state: "ConnectingToLkRoom" }
| {
state: "ConnectedToLkRoom";
livekitConnectionState$: Observable<LivekitConenctionState>;
livekitConnectionState$: Behavior<LivekitConenctionState>;
}
| { state: "FailedToStart"; error: Error }
| { state: "Stopped" };
@@ -82,6 +82,8 @@ export class Connection {
public readonly livekitRoom: LivekitRoom;
private scope: ObservableScope;
/**
* An observable of the participants that are publishing on this connection. (Excluding our local participant)
* This is derived from `participantsIncludingSubscribers$` and `remoteTransports$`.
@@ -154,7 +156,9 @@ export class Connection {
this._state$.next({
state: "ConnectedToLkRoom",
livekitConnectionState$: connectionStateObserver(this.livekitRoom),
livekitConnectionState$: this.scope.behavior(
connectionStateObserver(this.livekitRoom),
),
});
} catch (error) {
this.logger.debug(`Failed to connect to LiveKit room: ${error}`);
@@ -209,6 +213,7 @@ export class Connection {
);
const { transport, client, scope } = opts;
this.scope = scope;
this.livekitRoom = opts.livekitRoomFactory();
this.transport = transport;
this.client = client;