Skip to content

Commit

Permalink
Allow track placeholders to be pinned (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Nov 1, 2023
1 parent 4f6159e commit 01b0418
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-parrots-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/components-react": patch
---

Allow track placeholders to be pinned
4 changes: 2 additions & 2 deletions packages/react/src/context/pin-context.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { PinState, TrackReference } from '@livekit/components-core';
import type { PinState, TrackReferenceOrPlaceholder } from '@livekit/components-core';
import type * as React from 'react';

/** @internal */
export type PinAction =
| {
msg: 'set_pin';
trackReference: TrackReference;
trackReference: TrackReferenceOrPlaceholder;
}
| { msg: 'clear_pin' };

Expand Down
8 changes: 2 additions & 6 deletions packages/react/src/hooks/useFocusToggle.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { TrackReferenceOrPlaceholder } from '@livekit/components-core';
import {
setupFocusToggle,
isTrackReferencePinned,
isTrackReference,
} from '@livekit/components-core';
import { setupFocusToggle, isTrackReferencePinned } from '@livekit/components-core';
import type { Track, Participant } from 'livekit-client';
import { useEnsureParticipant, useMaybeLayoutContext } from '../context';
import { mergeProps } from '../mergeProps';
Expand Down Expand Up @@ -65,7 +61,7 @@ export function useFocusToggle({ trackRef, trackSource, participant, props }: Us
props.onClick?.(event);

// Set or clear focus based on current focus state.
if (trackRef && isTrackReference(trackRef)) {
if (trackRef) {
if (inFocus) {
layoutContext?.pin.dispatch?.({
msg: 'clear_pin',
Expand Down

0 comments on commit 01b0418

Please sign in to comment.