Skip to content

Commit ebe78fb

Browse files
davidzhaolukasIO
andauthored
use JS SDK's isLocal check (#1050)
Co-authored-by: lukasIO <[email protected]>
1 parent 207ce97 commit ebe78fb

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

.changeset/wise-ghosts-talk.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@livekit/components-core": patch
3+
"@livekit/components-react": patch
4+
---
5+
6+
use JS SDK's isLocal check

packages/core/src/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import type { Participant, TrackPublication } from 'livekit-client';
2-
import { LocalParticipant, RemoteParticipant } from 'livekit-client';
32

4-
import type { PinState } from './types';
53
import type { TrackReference } from './track-reference';
64
import { isEqualTrackRef } from './track-reference';
5+
import type { PinState } from './types';
76

87
export function isLocal(p: Participant) {
9-
return p instanceof LocalParticipant;
8+
return p.isLocal;
109
}
1110

1211
export function isRemote(p: Participant) {
13-
return p instanceof RemoteParticipant;
12+
return !p.isLocal;
1413
}
1514

1615
export const attachIfSubscribed = (

packages/react/src/components/RoomAudioRenderer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getTrackReferenceId, isLocal } from '@livekit/components-core';
1+
import { getTrackReferenceId } from '@livekit/components-core';
22
import { Track } from 'livekit-client';
33
import * as React from 'react';
44
import { useTracks } from '../hooks';
@@ -36,7 +36,7 @@ export function RoomAudioRenderer({ volume, muted }: RoomAudioRendererProps) {
3636
updateOnlyOn: [],
3737
onlySubscribed: true,
3838
},
39-
).filter((ref) => !isLocal(ref.participant) && ref.publication.kind === Track.Kind.Audio);
39+
).filter((ref) => !ref.participant.isLocal && ref.publication.kind === Track.Kind.Audio);
4040

4141
return (
4242
<div style={{ display: 'none' }}>

packages/react/src/hooks/useMediaTrackBySourceOrName.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { TrackIdentifier } from '@livekit/components-core';
2-
import { isTrackReference } from '@livekit/components-core';
3-
import { setupMediaTrack, log, isLocal, getTrackByIdentifier } from '@livekit/components-core';
2+
import {
3+
getTrackByIdentifier,
4+
isTrackReference,
5+
log,
6+
setupMediaTrack,
7+
} from '@livekit/components-core';
48
import * as React from 'react';
59
import { mergeProps } from '../utils';
610

@@ -52,7 +56,7 @@ export function useMediaTrackBySourceOrName(
5256
}
5357
if (
5458
options.element?.current &&
55-
!(isLocal(observerOptions.participant) && track?.kind === 'audio')
59+
!(observerOptions.participant.isLocal && track?.kind === 'audio')
5660
) {
5761
track.attach(options.element.current);
5862
}

0 commit comments

Comments
 (0)