fix initial selection when using controlled media

This commit is contained in:
Timo
2025-06-25 12:14:05 +02:00
parent daa931c3c4
commit 131bdc3522
2 changed files with 13 additions and 10 deletions

View File

@@ -50,7 +50,7 @@ export const setPipEnabled$ = new Subject<boolean>();
export const availableOutputDevices$ = new Subject<OutputDevice[]>(); export const availableOutputDevices$ = new Subject<OutputDevice[]>();
export const outputDevice$ = new Subject<string | undefined>(); export const outputDevice$ = new Subject<string>();
/** /**
* This allows the os to mute the call if the user * This allows the os to mute the call if the user

View File

@@ -269,16 +269,19 @@ class ControlledAudioOutput
this.deviceSelection$.next(id); this.deviceSelection$.next(id);
} }
public readonly selected$ = merge( public readonly selected$ = combineLatest([
this.deviceSelection$, this.available$,
controlledOutputSelection$, merge(
).pipe( controlledOutputSelection$.pipe(startWith(undefined)),
startWith<string | undefined>(undefined), this.deviceSelection$,
map((id) =>
id === undefined
? undefined
: { id, virtualEarpiece: id === EARPIECE_CONFIG_ID },
), ),
]).pipe(
map(([available, selectId]) => {
const id = selectId ?? available.keys().next().value;
return id
? { id, virtualEarpiece: id === EARPIECE_CONFIG_ID }
: undefined;
}),
this.scope.state(), this.scope.state(),
); );