Show 'reconnecting' message when disconnected from LiveKit

This commit is contained in:
Robin
2025-08-20 13:32:42 +02:00
parent 1a1e5a9db8
commit 3da9013426

View File

@@ -11,6 +11,7 @@ import {
observeParticipantMedia, observeParticipantMedia,
} from "@livekit/components-core"; } from "@livekit/components-core";
import { import {
ConnectionState,
type Room as LivekitRoom, type Room as LivekitRoom,
type LocalParticipant, type LocalParticipant,
LocalVideoTrack, LocalVideoTrack,
@@ -425,7 +426,7 @@ export class CallViewModel extends ViewModel {
private readonly remoteParticipantHolds$ = this.scope.behavior< private readonly remoteParticipantHolds$ = this.scope.behavior<
RemoteParticipant[][] RemoteParticipant[][]
>( >(
this.connectionState$.pipe( this.livekitConnectionState$.pipe(
withLatestFrom(this.rawRemoteParticipants$), withLatestFrom(this.rawRemoteParticipants$),
mergeMap(([s, ps]) => { mergeMap(([s, ps]) => {
// Whenever we switch focuses, we should retain all the previous // Whenever we switch focuses, we should retain all the previous
@@ -438,7 +439,7 @@ export class CallViewModel extends ViewModel {
// Wait for time to pass and the connection state to have changed // Wait for time to pass and the connection state to have changed
forkJoin([ forkJoin([
timer(POST_FOCUS_PARTICIPANT_UPDATE_DELAY_MS), timer(POST_FOCUS_PARTICIPANT_UPDATE_DELAY_MS),
this.connectionState$.pipe( this.livekitConnectionState$.pipe(
filter((s) => s !== ECAddonConnectionState.ECSwitchingFocus), filter((s) => s !== ECAddonConnectionState.ECSwitchingFocus),
take(1), take(1),
), ),
@@ -519,8 +520,14 @@ export class CallViewModel extends ViewModel {
), ),
); );
// TODO: Account for LiveKit connection state too private readonly connected$ = this.scope.behavior(
private readonly connected$ = this.matrixConnected$; and$(
this.matrixConnected$,
this.livekitConnectionState$.pipe(
map((state) => state === ConnectionState.Connected),
),
),
);
/** /**
* Whether we should tell the user that we're reconnecting to the call. * Whether we should tell the user that we're reconnecting to the call.
@@ -1541,7 +1548,7 @@ export class CallViewModel extends ViewModel {
private readonly livekitRoom: LivekitRoom, private readonly livekitRoom: LivekitRoom,
private readonly mediaDevices: MediaDevices, private readonly mediaDevices: MediaDevices,
private readonly options: CallViewModelOptions, private readonly options: CallViewModelOptions,
private readonly connectionState$: Observable<ECConnectionState>, private readonly livekitConnectionState$: Observable<ECConnectionState>,
private readonly handsRaisedSubject$: Observable< private readonly handsRaisedSubject$: Observable<
Record<string, RaisedHandInfo> Record<string, RaisedHandInfo>
>, >,