Almost running

- NEVER use undefined as the default for behaviors (FOOTGUN)
This commit is contained in:
Timo K
2025-11-07 12:32:29 +01:00
parent 92fdce33ea
commit 28047217b8
13 changed files with 83 additions and 34 deletions

View File

@@ -288,7 +288,7 @@ export const createLocalMembership$ = ({
};
const requestConnect = (): LocalMemberConnectionState => {
if (state.livekit$.value === null) {
if (state.livekit$.value.state === LivekitState.Uninitialized) {
startTracks();
state.livekit$.next({ state: LivekitState.Connecting });
combineLatest([publisher$, tracks$], (publisher, tracks) => {
@@ -302,7 +302,7 @@ export const createLocalMembership$ = ({
});
});
}
if (state.matrix$.value.state !== MatrixState.Disconnected) {
if (state.matrix$.value.state === MatrixState.Disconnected) {
state.matrix$.next({ state: MatrixState.Connecting });
localTransport$.pipe(
tap((transport) => {
@@ -438,6 +438,7 @@ export const createLocalMembership$ = ({
return of(false);
}),
),
null,
);
const toggleScreenSharing =

View File

@@ -67,18 +67,22 @@ export const createLocalTransport$ = ({
*/
const oldestMemberTransport$ = scope.behavior(
memberships$.pipe(
mapEpoch((memberships) => memberships[0].getTransport(memberships[0])),
first((t) => t != undefined && isLivekitTransport(t)),
mapEpoch(
(memberships) => memberships[0]?.getTransport(memberships[0]) ?? null,
),
first((t) => t != null && isLivekitTransport(t)),
),
undefined,
null,
);
/**
* The transport that we would personally prefer to publish on (if not for the
* transport preferences of others, perhaps).
*/
const preferredTransport$: Behavior<LivekitTransport | undefined> =
scope.behavior(from(makeTransport(client, roomId)), undefined);
const preferredTransport$: Behavior<LivekitTransport | null> = scope.behavior(
from(makeTransport(client, roomId)),
null,
);
/**
* The transport we should advertise in our MatrixRTC membership.
@@ -89,7 +93,6 @@ export const createLocalTransport$ = ({
(useOldestMember, oldestMemberTransport, preferredTransport) =>
useOldestMember ? oldestMemberTransport : preferredTransport,
).pipe<LivekitTransport>(distinctUntilChanged(deepCompare)),
undefined,
);
return advertisedTransport$;
};
@@ -103,7 +106,6 @@ async function makeTransportInternal(
logger.log("Searching for a preferred transport");
//TODO refactor this to use the jwt service returned alias.
const livekitAlias = roomId;
// TODO-MULTI-SFU: Either remove this dev tool or make it more official
const urlFromStorage =
localStorage.getItem("robin-matrixrtc-auth") ??

View File

@@ -307,6 +307,7 @@ export class Publisher {
return track instanceof LocalVideoTrack ? track : null;
}),
),
null,
);
trackProcessorSync(track$, trackerProcessorState$);
}