diff --git a/src/state/CallViewModel/localMember/Publisher.test.ts b/src/state/CallViewModel/localMember/Publisher.test.ts index 941b5956..78f8f9c4 100644 --- a/src/state/CallViewModel/localMember/Publisher.test.ts +++ b/src/state/CallViewModel/localMember/Publisher.test.ts @@ -98,14 +98,19 @@ describe("Publisher", () => { ( connection.livekitRoom.localParticipant.createTracks as Mock - ).mockResolvedValue([{}, {}]); + ).mockResolvedValue([ + { + kind: "audio", + mute: vi.fn(), + }, + ]); await expect(publisher.createAndSetupTracks()).resolves.not.toThrow(); expect( connection.livekitRoom.localParticipant.createTracks, ).toHaveBeenCalledOnce(); - // failiour due to localParticipant.publishTrack + // failure due to localParticipant.publishTrack ( connection.livekitRoom.localParticipant.publishTrack as Mock ).mockRejectedValue(Error("testError")); @@ -114,7 +119,7 @@ describe("Publisher", () => { new FailToStartLivekitConnection("testError"), ); - // does not try other conenction after the first one failed + // does not try other connection after the first one failed expect( connection.livekitRoom.localParticipant.publishTrack, ).toHaveBeenCalledTimes(1); @@ -145,7 +150,7 @@ describe("Publisher", () => { expect( connection.livekitRoom.localParticipant.publishTrack, - ).toHaveBeenCalledTimes(3); + ).toHaveBeenCalledTimes(2); }); }); diff --git a/src/state/CallViewModel/localMember/Publisher.ts b/src/state/CallViewModel/localMember/Publisher.ts index 6a1c5909..4990391e 100644 --- a/src/state/CallViewModel/localMember/Publisher.ts +++ b/src/state/CallViewModel/localMember/Publisher.ts @@ -191,10 +191,14 @@ export class Publisher { // or only use the low level create/publish APIs and have our own pending publication protection. // Maybe we could change the livekit api to pre-load tracks without publishing them yet? // Are we sure this is needed at all? What are the gains? - const isEnabled = - track.kind === Track.Kind.Audio - ? this.muteStates.audio.enabled$.value - : this.muteStates.video.enabled$.value; + let isEnabled: boolean; + if (track.kind === Track.Kind.Audio) { + isEnabled = this.muteStates.audio.enabled$.value; + } else if (track.kind === Track.Kind.Video) { + isEnabled = this.muteStates.video.enabled$.value; + } else { + throw new Error("Unsupported track kind " + track.kind); + } if (!isEnabled) { // TODO should we also drop it?