Skip to content

Improve PreJoin Component and add custom participant placeholders #1129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Simba14
Copy link

@Simba14 Simba14 commented Apr 15, 2025

This PR improves the PreJoin component by fixing a few bugs, improving the UX and adding some new features.

Bug fixes:

  • Video feed no longer flickers when enabling / disabling the audio (Due to Video stream being re-rendered each time)

Feature:

  • Display selected devices
  • Enabled selecting of device when audio / video is disabled.
  • Improve UI of selecting device section to make it clearer which part disables / enables and which part selects the device.
  • Also extended the ParticipantTile by adding the placeholders prop. This allows placeholders to be unique for each participant e.g. if they have an image associated with their account.

placeholders is an object where the key is the participant id and the value is a React node.

In order to implement the selected device feature, I added new hook - useSelectedDevice to return the current selected device by the user.

Copy link

changeset-bot bot commented Apr 15, 2025

🦋 Changeset detected

Latest commit: 8a0c30c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@livekit/components-react Minor
@livekit/components-styles Minor
@livekit/component-example-next Patch
@livekit/components-js-docs Patch
@livekit/component-docs-storybook Patch
@livekit/components-docs-gen Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Apr 15, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Simba14

thanks for taking the time to suggest and implement these changes.
It's clear that you've put a lot of thought into it.

I have some reservations about some of these changes though.
I tried to outline my concerns in some comments, feel free to correct my assumptions if any sound wrong to you.

The PR itself is (very) big and touches upon a bunch of things at the same time. We can keep this PR open to discuss your proposed changes. Whatever changes remain it would be nice to have them separated in PRs with smaller scope.

* ```
* @public
*/
export function useSelectedDevice<T extends LocalVideoTrack | LocalAudioTrack>({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within the livekit-client SDK there's the concept of an active device which is currently used by the user.
That's not as useful for prejoin as of now, but it would mirror the implementation in the client SDK more closely.

};
}, [JSON.stringify(options, roomOptionsStringifyReplacer), onError, trackLock]);
// Handle audio track
React.useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way it was previously implemented was in order to avoid separate permission prompts when entering the site.
With your proposed implementation it would result in two different permission requests.

I don't think that's an improvement worth the additional complexity.

/>
<div className="lk-button-group-menu-pre-join">
<label className="lk-selected-device-label">
{selectedAudioDevice?.label || micLabel}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice idea, but the handling could be moved into the instead in order to allow for the same experience everywhere (not only in the prejoin).
Keeping it simple with a useDeviceInfo(track) hook that only returns the MediaDeviceInfo for that use case seems more appropriate

@@ -1,6 +1,6 @@
{
"name": "@livekit/components-styles",
"version": "1.1.4",
"version": "1.1.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versions are automatically bumped by the CI, bumping them in PRs has the effect of skipping versions or unintentionally publishing them

display: flex;
flex-wrap: nowrap;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these style changes aren't clear to me, why are they needed?

@@ -73,6 +73,7 @@ export interface ParticipantTileProps extends React.HTMLAttributes<HTMLDivElemen
disableSpeakingIndicator?: boolean;

onParticipantClick?: (event: ParticipantClickEvent) => void;
placeholders?: { [index: string]: React.ReactNode };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big fan of passing the whole map to each participant tile.
A pattern where the component can take a single placeholder as a ReactNode seems preferable to me.
In general the codebase tries to avoid passing of components as props and rather works with slottable components (as children). We're already using those for ParticipantTile as custom tile renderings though, so I'm not totally against an exception here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants