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) => { async (vm) => {
// Switch to back camera // Switch to back camera
getValue(vm.switchCamera$)!(); getValue(vm.switchCamera$)!();
expect(restartTrack).toHaveBeenCalledTimes(1); expect(restartTrack).toHaveBeenCalledExactlyOnceWith({
expect(restartTrack).toHaveBeenCalledWith({ facingMode: "environment" }); facingMode: "environment",
});
await waitFor(() => { await waitFor(() => {
expect(selectVideoInput).toHaveBeenCalledTimes(1); expect(selectVideoInput).toHaveBeenCalledTimes(1);
expect(selectVideoInput).toHaveBeenCalledWith("back camera"); expect(selectVideoInput).toHaveBeenCalledWith("back camera");

View File

@@ -456,11 +456,13 @@ export class LocalUserMediaViewModel extends BaseUserMediaViewModel {
const track = v?.publication?.track; const track = v?.publication?.track;
if (!(track instanceof LocalVideoTrack)) return of(null); if (!(track instanceof LocalVideoTrack)) return of(null);
return merge( 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( fromEvent(track, TrackEvent.Restarted).pipe(
startWith(null), startWith(null),
map(() => track), map(() => track),
), ),
// When the track object is muted, reset it to null.
fromEvent(track, TrackEvent.Muted).pipe(map(() => null)), fromEvent(track, TrackEvent.Muted).pipe(map(() => null)),
); );
}), }),