diff --git a/src/state/CallViewModel/CallViewModel.ts b/src/state/CallViewModel/CallViewModel.ts index 6c1da854..c57f9187 100644 --- a/src/state/CallViewModel/CallViewModel.ts +++ b/src/state/CallViewModel/CallViewModel.ts @@ -229,7 +229,7 @@ export class CallViewModel { private connectionManager = createConnectionManager$({ scope: this.scope, connectionFactory: this.connectionFactory, - inputTransports$: this.allTransports$, + inputTransports$: this.membershipsAndTransports.transports$, logger: logger, }); diff --git a/src/state/CallViewModel/localMember/LocalMembership.ts b/src/state/CallViewModel/localMember/LocalMembership.ts index 1b9a6d46..c7e2382f 100644 --- a/src/state/CallViewModel/localMember/LocalMembership.ts +++ b/src/state/CallViewModel/localMember/LocalMembership.ts @@ -32,7 +32,7 @@ import { switchMap, tap, } from "rxjs"; -import { type Logger, logger } from "matrix-js-sdk/lib/logger"; +import { type Logger } from "matrix-js-sdk/lib/logger"; import { type Behavior } from "../../Behavior"; import { type IConnectionManager } from "../remoteMembers/ConnectionManager"; @@ -54,7 +54,7 @@ import { PosthogAnalytics } from "../../../analytics/PosthogAnalytics.ts"; import { MatrixRTCMode } from "../../../settings/settings.ts"; import { Config } from "../../../config/Config.ts"; import { type Connection } from "../remoteMembers/Connection.ts"; -const logger = rootLogger.getChild("[LocalMembership]"); + export enum LivekitState { Uninitialized = "uninitialized", Connecting = "connecting", @@ -220,39 +220,37 @@ export const createLocalMembership$ = ({ /** * Whether we are connected to the MatrixRTC session. */ - const homeserverConnected$ = scope - .behavior( - // To consider ourselves connected to MatrixRTC, we check the following: - and$( - // The client is connected to the sync loop - ( - fromEvent(matrixRoom.client, ClientEvent.Sync) as Observable< - [SyncState] - > - ).pipe( - startWith([matrixRoom.client.getSyncState()]), - map(([state]) => state === SyncState.Syncing), - ), - // Room state observed by session says we're connected - fromEvent(matrixRTCSession, MembershipManagerEvent.StatusChanged).pipe( - startWith(null), - map(() => matrixRTCSession.membershipStatus === Status.Connected), - ), - // Also watch out for warnings that we've likely hit a timeout and our - // delayed leave event is being sent (this condition is here because it - // provides an earlier warning than the sync loop timeout, and we wouldn't - // see the actual leave event until we reconnect to the sync loop) - fromEvent(matrixRTCSession, MembershipManagerEvent.ProbablyLeft).pipe( - startWith(null), - map(() => matrixRTCSession.probablyLeft !== true), - ), + const homeserverConnected$ = scope.behavior( + // To consider ourselves connected to MatrixRTC, we check the following: + and$( + // The client is connected to the sync loop + ( + fromEvent(matrixRoom.client, ClientEvent.Sync) as Observable< + [SyncState] + > + ).pipe( + startWith([matrixRoom.client.getSyncState()]), + map(([state]) => state === SyncState.Syncing), ), - ) - .pipe( + // Room state observed by session says we're connected + fromEvent(matrixRTCSession, MembershipManagerEvent.StatusChanged).pipe( + startWith(null), + map(() => matrixRTCSession.membershipStatus === Status.Connected), + ), + // Also watch out for warnings that we've likely hit a timeout and our + // delayed leave event is being sent (this condition is here because it + // provides an earlier warning than the sync loop timeout, and we wouldn't + // see the actual leave event until we reconnect to the sync loop) + fromEvent(matrixRTCSession, MembershipManagerEvent.ProbablyLeft).pipe( + startWith(null), + map(() => matrixRTCSession.probablyLeft !== true), + ), + ).pipe( tap((connected) => { prefixLogger.info(`Homeserver connected update: ${connected}`); }), - ); + ), + ); // /** // * Whether we are "fully" connected to the call. Accounts for both the @@ -609,10 +607,11 @@ async function enterRTCSession( }, ); if (widget) { - try { - await widget.api.transport.send(ElementWidgetActions.JoinCall, {}); - } catch (e) { - logger.error("Failed to send join action", e); - } + // try { + await widget.api.transport.send(ElementWidgetActions.JoinCall, {}); + // TODO Why catch and swallow? + // } catch (e) { + // logger.error("Failed to send join action", e); + // } } } diff --git a/src/state/ObservableScope.ts b/src/state/ObservableScope.ts index f2f8c355..27f501c7 100644 --- a/src/state/ObservableScope.ts +++ b/src/state/ObservableScope.ts @@ -19,7 +19,6 @@ import { take, takeUntil, } from "rxjs"; -import { logger } from "matrix-js-sdk/lib/logger"; import { type Behavior } from "./Behavior";