Skip to content

Commit 35a44b0

Browse files
authored
Fix local participant track being hidden when muted (#1244)
1 parent 04f5e29 commit 35a44b0

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

.changeset/shy-oranges-pick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@livekit/components-react': patch
3+
---
4+
5+
Fix bug in useSession not exposing tracks when muted and switch empty value from null to undefined

packages/react/src/hooks/useSession.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ type SessionStateConnecting = SessionStateCommon & {
8888
isConnected: false;
8989

9090
local: {
91-
cameraTrack: null;
92-
microphoneTrack: null;
91+
cameraTrack: undefined;
92+
microphoneTrack: undefined;
9393
};
9494
};
9595

@@ -101,8 +101,8 @@ type SessionStateConnected = SessionStateCommon & {
101101
isConnected: true;
102102

103103
local: {
104-
cameraTrack: TrackReference | null;
105-
microphoneTrack: TrackReference | null;
104+
cameraTrack?: TrackReference;
105+
microphoneTrack?: TrackReference;
106106
};
107107
};
108108

@@ -111,8 +111,8 @@ type SessionStateDisconnected = SessionStateCommon & {
111111
isConnected: false;
112112

113113
local: {
114-
cameraTrack: null;
115-
microphoneTrack: null;
114+
cameraTrack: undefined;
115+
microphoneTrack: undefined;
116116
};
117117
};
118118

@@ -367,8 +367,8 @@ export function useSession(
367367
const { localParticipant } = useLocalParticipant({ room });
368368
const cameraPublication = localParticipant.getTrackPublication(Track.Source.Camera);
369369
const localCamera = React.useMemo(() => {
370-
if (!cameraPublication || cameraPublication.isMuted) {
371-
return null;
370+
if (!cameraPublication) {
371+
return undefined;
372372
}
373373
return {
374374
source: Track.Source.Camera,
@@ -378,8 +378,8 @@ export function useSession(
378378
}, [localParticipant, cameraPublication, cameraPublication?.isMuted]);
379379
const microphonePublication = localParticipant.getTrackPublication(Track.Source.Microphone);
380380
const localMicrophone = React.useMemo(() => {
381-
if (!microphonePublication || microphonePublication.isMuted) {
382-
return null;
381+
if (!microphonePublication) {
382+
return undefined;
383383
}
384384
return {
385385
source: Track.Source.Microphone,
@@ -441,8 +441,8 @@ export function useSession(
441441
...generateDerivedConnectionStateValues(ConnectionState.Connecting),
442442

443443
local: {
444-
cameraTrack: null,
445-
microphoneTrack: null,
444+
cameraTrack: undefined,
445+
microphoneTrack: undefined,
446446
},
447447
};
448448

@@ -469,8 +469,8 @@ export function useSession(
469469
...generateDerivedConnectionStateValues(ConnectionState.Disconnected),
470470

471471
local: {
472-
cameraTrack: null,
473-
microphoneTrack: null,
472+
cameraTrack: undefined,
473+
microphoneTrack: undefined,
474474
},
475475
};
476476
}

0 commit comments

Comments
 (0)