review: Move the all advertised/active down to the LocalMember

And let the local member use it properly to send membership event and publish media
This commit is contained in:
Valere
2026-04-09 15:22:10 +02:00
parent 08006d640a
commit 40dacd523b
4 changed files with 94 additions and 60 deletions

View File

@@ -120,7 +120,6 @@ import {
type LocalMatrixLivekitMember,
type RemoteMatrixLivekitMember,
type MatrixLivekitMember,
areLivekitTransportsEqual,
} from "./remoteMembers/MatrixLivekitMembers.ts";
import {
type AutoLeaveReason,
@@ -518,26 +517,6 @@ export function createCallViewModel$(
),
);
// Observe the transport we should publish
const publishingTransport$ = localTransport$.pipe(
// observe the active$ transport
switchMap((t) => {
return combineLatest([t.active$, t.advertised$]).pipe(
map(([active, advertised]) => {
if (active?.transport) {
// use the active one (oldest member transport)
return active.transport;
} else {
// There is no active transport, we might just be the first member in the call
// so use the advertised to start
return advertised;
}
}),
);
}),
distinctUntilChanged(areLivekitTransportsEqual),
);
const localMembership = createLocalMembership$({
scope,
homeserverConnected: createHomeserverConnected$(
@@ -567,7 +546,7 @@ export function createCallViewModel$(
},
connectionManager,
matrixRTCSession,
localTransport$: scope.behavior(publishingTransport$),
localTransport$,
logger: logger.getChild(`[${Date.now()}]`),
});