-
Notifications
You must be signed in to change notification settings - Fork 105
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
Simba14
wants to merge
15
commits into
livekit:main
Choose a base branch
from
a-little-world:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+8,101
−2,781
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
baaee68
Tims pre-join patch
tbscode f4ec238
updated patch package version
tbscode 2064805
update ParticipantTile to alllow for custom placeholder
Simba14 b1638ef
update packages
Simba14 29afb7a
add build of new version
Simba14 acb1a4f
reversed version
tbscode a5f3ff3
update lock file
tbscode 45e37fc
merged seans updates
tbscode 7a7507e
resync fork with upstream
Simba14 ccd2775
Improve PreJoin screen
Simba14 2e43693
bump version
Simba14 ae713f3
pack react 2.9.0 package
Simba14 5296dc6
Merge pull request #1 from a-little-world/feat/pre-join-improvements
Simba14 785e4ec
remove packed packages
Simba14 8a0c30c
add changeset
Simba14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@livekit/components-react': minor | ||
'@livekit/components-styles': minor | ||
--- | ||
|
||
Improves the PreJoin component and allows for custom placeholders for each participant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { type LocalAudioTrack, type LocalVideoTrack } from 'livekit-client'; | ||
import * as React from 'react'; | ||
import { useMediaDevices } from './useMediaDevices'; | ||
|
||
/** | ||
* /** | ||
* The `useSelectedDevice` hook returns the current selected device (audio or video) of the participant. | ||
* | ||
* @example | ||
* ```tsx | ||
* const { selectedDevice } = useSelectedDevice({ | ||
* kind: 'videoinput', | ||
* track: track, | ||
* }); | ||
* | ||
* <div> | ||
* {selectedDevice?.label} | ||
* </div> | ||
* ``` | ||
* @public | ||
*/ | ||
export function useSelectedDevice<T extends LocalVideoTrack | LocalAudioTrack>({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
kind, | ||
track, | ||
deviceId, | ||
}: { | ||
kind: 'videoinput' | 'audioinput'; | ||
track?: T; | ||
deviceId?: string; | ||
}) { | ||
const [deviceError, setDeviceError] = React.useState<Error | null>(null); | ||
|
||
const devices = useMediaDevices({ kind }); | ||
const [selectedDevice, setSelectedDevice] = React.useState<MediaDeviceInfo | undefined>( | ||
undefined, | ||
); | ||
const [localDeviceId, setLocalDeviceId] = React.useState<string | undefined>(deviceId); | ||
|
||
const prevDeviceId = React.useRef(localDeviceId); | ||
|
||
const getDeviceId = async () => { | ||
try { | ||
const newDeviceId = await track?.getDeviceId(false); | ||
if (newDeviceId && localDeviceId !== newDeviceId) { | ||
prevDeviceId.current = newDeviceId; | ||
setLocalDeviceId(newDeviceId); | ||
} | ||
} catch (e) { | ||
if (e instanceof Error) { | ||
setDeviceError(e); | ||
} | ||
} | ||
}; | ||
|
||
React.useEffect(() => { | ||
if (track) getDeviceId(); | ||
}, [track]); | ||
|
||
React.useEffect(() => { | ||
// in case track doesn't exist, utilize the deviceId passed in | ||
if (!track) setLocalDeviceId(deviceId); | ||
}, [deviceId]); | ||
|
||
React.useEffect(() => { | ||
setSelectedDevice(devices?.find((dev) => dev.deviceId === localDeviceId)); | ||
}, [localDeviceId, devices]); | ||
|
||
return { | ||
selectedDevice, | ||
deviceError, | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.