|
1 |
| -import { |
2 |
| - LocalParticipant, |
3 |
| - Participant, |
4 |
| - RemoteParticipant, |
5 |
| - Track, |
6 |
| - TrackPublication, |
7 |
| -} from 'livekit-client'; |
| 1 | +import { LocalParticipant, Participant, RemoteParticipant, TrackPublication } from 'livekit-client'; |
8 | 2 | import type { ClassNames } from '@livekit/components-styles/dist/types/general/styles.css';
|
9 | 3 | import type { UnprefixedClassNames } from '@livekit/components-styles/dist/types_unprefixed/styles.scss';
|
10 | 4 | import { cssPrefix } from './constants';
|
11 |
| -import { PinState } from './types'; |
| 5 | +import { PinState, TrackParticipantPair } from './types'; |
12 | 6 | export function kebabize(str: string) {
|
13 | 7 | return str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());
|
14 | 8 | }
|
@@ -43,41 +37,16 @@ export const attachIfSubscribed = (
|
43 | 37 | };
|
44 | 38 |
|
45 | 39 | export function isParticipantTrackPinned(
|
46 |
| - participant: Participant, |
47 |
| - focusState: PinState | undefined, |
48 |
| - source: Track.Source, |
| 40 | + trackParticipantPair: TrackParticipantPair, |
| 41 | + pinState: PinState | undefined, |
49 | 42 | ): boolean {
|
50 |
| - if (focusState === undefined) { |
51 |
| - console.warn(`focusState not set: `, focusState); |
52 |
| - return false; |
53 |
| - } |
54 |
| - |
55 |
| - if (focusState.pinnedParticipant === undefined || focusState.pinnedSource === undefined) { |
56 |
| - console.warn(`focusState not set: `, focusState); |
57 |
| - return false; |
58 |
| - } |
| 43 | + const { track, participant } = trackParticipantPair; |
59 | 44 |
|
60 |
| - if (focusState.pinnedSource !== source) { |
| 45 | + if (pinState === undefined) { |
61 | 46 | return false;
|
62 | 47 | }
|
63 | 48 |
|
64 |
| - if (focusState.pinnedParticipant.identity === participant.identity) { |
65 |
| - console.log(`Participant has same identity as pinned.`, focusState); |
66 |
| - switch (focusState.pinnedSource) { |
67 |
| - case Track.Source.Camera: |
68 |
| - return participant.isCameraEnabled; |
69 |
| - break; |
70 |
| - case Track.Source.ScreenShare: |
71 |
| - return participant.isScreenShareEnabled; |
72 |
| - break; |
73 |
| - |
74 |
| - default: |
75 |
| - return false; |
76 |
| - break; |
77 |
| - } |
78 |
| - } else { |
79 |
| - return false; |
80 |
| - } |
| 49 | + return pinState.pinnedSource === track.source && pinState.pinnedParticipant === participant; |
81 | 50 | }
|
82 | 51 |
|
83 | 52 | /**
|
|
0 commit comments