Skip to content

Commit f8a051e

Browse files
committed
Address review feedback
1 parent 0ed47c2 commit f8a051e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/state/MediaViewModel.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ test("switch cameras", async () => {
182182
async (vm) => {
183183
// Switch to back camera
184184
getValue(vm.switchCamera$)!();
185-
expect(restartTrack).toHaveBeenCalledTimes(1);
186-
expect(restartTrack).toHaveBeenCalledWith({ facingMode: "environment" });
185+
expect(restartTrack).toHaveBeenCalledExactlyOnceWith({
186+
facingMode: "environment",
187+
});
187188
await waitFor(() => {
188189
expect(selectVideoInput).toHaveBeenCalledTimes(1);
189190
expect(selectVideoInput).toHaveBeenCalledWith("back camera");

src/state/MediaViewModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,13 @@ export class LocalUserMediaViewModel extends BaseUserMediaViewModel {
456456
const track = v?.publication?.track;
457457
if (!(track instanceof LocalVideoTrack)) return of(null);
458458
return merge(
459-
// Watch for track restarts because they indicate a camera switch
459+
// Watch for track restarts because they indicate a camera switch.
460+
// This event is also emitted when unmuting the track object.
460461
fromEvent(track, TrackEvent.Restarted).pipe(
461462
startWith(null),
462463
map(() => track),
463464
),
465+
// When the track object is muted, reset it to null.
464466
fromEvent(track, TrackEvent.Muted).pipe(map(() => null)),
465467
);
466468
}),

0 commit comments

Comments
 (0)