Fix locale-dependent default device detection#1313
Conversation
The previous check used label.startsWith('Default') to detect if a
track is using the system default device, but this only works when
the browser locale is English. On other locales the label is
translated (e.g. 'Standard' in German).
Replaced with getSettings().deviceId === 'default' which is
locale-independent and directly checks what we actually care about.
Fixes #1194
|
@ctonneslan is attempting to deploy a commit to the LiveKit Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request was closed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1194
The default device detection was checking
label.startsWith('Default'), which only works when the browser is in English. On other locales Chrome translates the label (e.g. "Standard" in German, "Par defaut" in French), so the check would fail and the UI wouldn't show "default" as the active device.Replaced with
track.getSettings().deviceId === 'default', which checks the actual device ID instead of the human-readable label. This is locale-independent and directly checks what we care about.Added a small
isDefaultDevice()helper with a try/catch in casegetSettings()isn't available (older browsers), in which case it falls back tofalse(same as the old behavior when the label didn't match).