Address review feedback

This commit is contained in:
Robin
2025-08-20 12:07:06 +02:00
parent 0ed47c2588
commit f8a051ee11
2 changed files with 6 additions and 3 deletions

View File

@@ -182,8 +182,9 @@ test("switch cameras", async () => {
async (vm) => {
// Switch to back camera
getValue(vm.switchCamera$)!();
expect(restartTrack).toHaveBeenCalledTimes(1);
expect(restartTrack).toHaveBeenCalledWith({ facingMode: "environment" });
expect(restartTrack).toHaveBeenCalledExactlyOnceWith({
facingMode: "environment",
});
await waitFor(() => {
expect(selectVideoInput).toHaveBeenCalledTimes(1);
expect(selectVideoInput).toHaveBeenCalledWith("back camera");

View File

@@ -456,11 +456,13 @@ export class LocalUserMediaViewModel extends BaseUserMediaViewModel {
const track = v?.publication?.track;
if (!(track instanceof LocalVideoTrack)) return of(null);
return merge(
// Watch for track restarts because they indicate a camera switch
// Watch for track restarts because they indicate a camera switch.
// This event is also emitted when unmuting the track object.
fromEvent(track, TrackEvent.Restarted).pipe(
startWith(null),
map(() => track),
),
// When the track object is muted, reset it to null.
fromEvent(track, TrackEvent.Muted).pipe(map(() => null)),
);
}),