Remove un-necessary transport field, already accessible from connection

This commit is contained in:
Valere
2025-10-08 14:30:52 +02:00
parent f5ea734a5c
commit afe004c6e7

View File

@@ -563,7 +563,7 @@ export class CallViewModel extends ViewModel {
/** /**
* The transport over which we should be actively publishing our media. * The transport over which we should be actively publishing our media.
*/ */
private readonly localTransport$: Behavior<Async<LivekitTransport> | null> = private readonly localTransport$: Behavior<Async<LivekitTransport>> =
this.scope.behavior( this.scope.behavior(
this.transports$.pipe( this.transports$.pipe(
map((transports) => transports?.local ?? null), map((transports) => transports?.local ?? null),
@@ -571,7 +571,8 @@ export class CallViewModel extends ViewModel {
), ),
); );
private readonly localConnectionAndTransport$ = this.scope.behavior( private readonly localConnection$: Behavior<Async<PublishConnection>> =
this.scope.behavior(
this.localTransport$.pipe( this.localTransport$.pipe(
map( map(
(transport) => (transport) =>
@@ -583,27 +584,18 @@ export class CallViewModel extends ViewModel {
scope: this.scope, scope: this.scope,
remoteTransports$: this.remoteTransports$, remoteTransports$: this.remoteTransports$,
}; };
return { return new PublishConnection(
connection: new PublishConnection(
opts, opts,
this.mediaDevices, this.mediaDevices,
this.muteStates, this.muteStates,
this.e2eeLivekitOptions(), this.e2eeLivekitOptions(),
this.scope.behavior(this.trackProcessorState$), this.scope.behavior(this.trackProcessorState$),
), );
transport,
};
}), }),
), ),
), ),
); );
private readonly localConnection$ = this.scope.behavior(
this.localConnectionAndTransport$.pipe(
map((value) => value && mapAsync(value, ({ connection }) => connection)),
),
);
public readonly livekitConnectionState$ = this.scope.behavior( public readonly livekitConnectionState$ = this.scope.behavior(
this.localConnection$.pipe( this.localConnection$.pipe(
switchMap((c) => switchMap((c) =>
@@ -813,11 +805,11 @@ export class CallViewModel extends ViewModel {
}[] }[]
>( >(
// TODO: Move this logic into Connection/PublishConnection if possible // TODO: Move this logic into Connection/PublishConnection if possible
this.localConnectionAndTransport$ this.localConnection$
.pipe( .pipe(
switchMap((values) => { switchMap((values) => {
if (values?.state !== "ready") return []; if (values?.state !== "ready") return [];
const localConnection = values.value.connection; const localConnection = values.value;
const memberError = (): never => { const memberError = (): never => {
throw new Error("No room member for call membership"); throw new Error("No room member for call membership");
}; };