Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shy-oranges-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/components-react': patch
---

Fix bug in useSession not exposing tracks when muted and switch empty value from null to undefined
28 changes: 14 additions & 14 deletions packages/react/src/hooks/useSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ type SessionStateConnecting = SessionStateCommon & {
isConnected: false;

local: {
cameraTrack: null;
microphoneTrack: null;
cameraTrack: undefined;
microphoneTrack: undefined;
};
};

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

local: {
cameraTrack: TrackReference | null;
microphoneTrack: TrackReference | null;
cameraTrack?: TrackReference;
microphoneTrack?: TrackReference;
};
};

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

local: {
cameraTrack: null;
microphoneTrack: null;
cameraTrack: undefined;
microphoneTrack: undefined;
};
};

Expand Down Expand Up @@ -367,8 +367,8 @@ export function useSession(
const { localParticipant } = useLocalParticipant({ room });
const cameraPublication = localParticipant.getTrackPublication(Track.Source.Camera);
const localCamera = React.useMemo(() => {
if (!cameraPublication || cameraPublication.isMuted) {
return null;
if (!cameraPublication) {
return undefined;
}
return {
source: Track.Source.Camera,
Expand All @@ -378,8 +378,8 @@ export function useSession(
}, [localParticipant, cameraPublication, cameraPublication?.isMuted]);
const microphonePublication = localParticipant.getTrackPublication(Track.Source.Microphone);
const localMicrophone = React.useMemo(() => {
if (!microphonePublication || microphonePublication.isMuted) {
return null;
if (!microphonePublication) {
return undefined;
}
return {
source: Track.Source.Microphone,
Expand Down Expand Up @@ -441,8 +441,8 @@ export function useSession(
...generateDerivedConnectionStateValues(ConnectionState.Connecting),

local: {
cameraTrack: null,
microphoneTrack: null,
cameraTrack: undefined,
microphoneTrack: undefined,
},
};

Expand All @@ -469,8 +469,8 @@ export function useSession(
...generateDerivedConnectionStateValues(ConnectionState.Disconnected),

local: {
cameraTrack: null,
microphoneTrack: null,
cameraTrack: undefined,
microphoneTrack: undefined,
},
};
}
Expand Down