Skip to content

Commit

Permalink
Update focused placeholder to trackRef (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Jun 3, 2024
1 parent ca0847f commit 0761e96
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 562 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-rocks-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/components-react": patch
---

Update focused placeholder to trackRef
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
version: 9
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/size-limit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
version: 9
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: pnpm/action-setup@v2
with:
version: 8
version: 9
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/hooks/useFocusToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function useFocusToggle({ trackRef, props }: UseFocusToggleProps) {

const inFocus: boolean = React.useMemo(() => {
return isTrackReferencePinned(trackReference, layoutContext?.pin.state);
}, [trackRef, layoutContext?.pin.state]);
}, [trackReference, layoutContext?.pin.state]);

const mergedProps = React.useMemo(
() =>
Expand All @@ -52,7 +52,7 @@ export function useFocusToggle({ trackRef, props }: UseFocusToggleProps) {
}
},
}),
[props, className, trackRef, inFocus, layoutContext?.pin],
[props, className, trackReference, inFocus, layoutContext?.pin],
);

return { mergedProps, inFocus };
Expand Down
11 changes: 11 additions & 0 deletions packages/react/src/prefabs/VideoConference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,22 @@ export function VideoConference({
layoutContext.pin.dispatch?.({ msg: 'clear_pin' });
lastAutoFocusedScreenShareTrack.current = null;
}
if (focusTrack && !isTrackReference(focusTrack)) {
const updatedFocusTrack = tracks.find(
(tr) =>
tr.participant.identity === focusTrack.participant.identity &&
tr.source === focusTrack.source,
);
if (updatedFocusTrack !== focusTrack && isTrackReference(updatedFocusTrack)) {
layoutContext.pin.dispatch?.({ msg: 'set_pin', trackReference: updatedFocusTrack });
}
}
}, [
screenShareTracks
.map((ref) => `${ref.publication.trackSid}_${ref.publication.isSubscribed}`)
.join(),
focusTrack?.publication?.trackSid,
tracks,
]);

useWarnAboutMissingStyles();
Expand Down
Loading

0 comments on commit 0761e96

Please sign in to comment.