Procházet zdrojové kódy

feat: more user friendly default device label

Also fixes an issue where starting Chrome 90 air pods
no longer have the "Default -" prefix and the default
entry looks like a buggy duplicated one.
j8
Pawel Domas před 4 roky
rodič
revize
6f5e0b0321

+ 1
- 0
lang/main.json Zobrazit soubor

@@ -674,6 +674,7 @@
674 674
         "more": "More",
675 675
         "name": "Name",
676 676
         "noDevice": "None",
677
+        "sameAsSystem": "Same as system ({{label}})",
677 678
         "selectAudioOutput": "Audio output",
678 679
         "selectCamera": "Camera",
679 680
         "selectMic": "Microphone",

+ 24
- 6
react/features/settings/components/web/audio/AudioSettingsContent.js Zobrazit soubor

@@ -14,6 +14,20 @@ import SpeakerEntry from './SpeakerEntry';
14 14
 
15 15
 const browser = JitsiMeetJS.util.browser;
16 16
 
17
+/**
18
+ * Translates the default device label into a more user friendly one.
19
+ *
20
+ * @param {string} deviceId - The device Id.
21
+ * @param {string} label - The device label.
22
+ * @param {Function} t - The translation function.
23
+ * @returns {string}
24
+ */
25
+function transformDefaultDeviceLabel(deviceId, label, t) {
26
+    return deviceId === 'default'
27
+        ? t('settings.sameAsSystem', { label: label.replace('Default - ', '') })
28
+        : label;
29
+}
30
+
17 31
 export type Props = {
18 32
 
19 33
    /**
@@ -125,10 +139,12 @@ class AudioSettingsContent extends Component<Props, State> {
125 139
      *
126 140
      * @param {Object} data - An object with the deviceId, jitsiTrack & label of the microphone.
127 141
      * @param {number} index - The index of the element, used for creating a key.
142
+     * @param {Function} t - The translation function.
128 143
      * @returns {React$Node}
129 144
      */
130
-    _renderMicrophoneEntry(data, index) {
131
-        const { deviceId, label, jitsiTrack, hasError } = data;
145
+    _renderMicrophoneEntry(data, index, t) {
146
+        const { deviceId, jitsiTrack, hasError } = data;
147
+        const label = transformDefaultDeviceLabel(deviceId, data.label, t);
132 148
         const isSelected = deviceId === this.props.currentMicDeviceId;
133 149
 
134 150
         return (
@@ -149,10 +165,12 @@ class AudioSettingsContent extends Component<Props, State> {
149 165
      *
150 166
      * @param {Object} data - An object with the deviceId and label of the speaker.
151 167
      * @param {number} index - The index of the element, used for creating a key.
168
+     * @param {Function} t - The translation function.
152 169
      * @returns {React$Node}
153 170
      */
154
-    _renderSpeakerEntry(data, index) {
155
-        const { deviceId, label } = data;
171
+    _renderSpeakerEntry(data, index, t) {
172
+        const { deviceId } = data;
173
+        const label = transformDefaultDeviceLabel(deviceId, data.label, t);
156 174
         const key = `se-${index}`;
157 175
 
158 176
         return (
@@ -251,7 +269,7 @@ class AudioSettingsContent extends Component<Props, State> {
251 269
                         IconComponent = { IconMicrophoneHollow }
252 270
                         text = { t('settings.microphones') } />
253 271
                     {this.state.audioTracks.map((data, i) =>
254
-                        this._renderMicrophoneEntry(data, i),
272
+                        this._renderMicrophoneEntry(data, i, t),
255 273
                     )}
256 274
                     { outputDevices.length > 0 && (
257 275
                         <>
@@ -263,7 +281,7 @@ class AudioSettingsContent extends Component<Props, State> {
263 281
                     )
264 282
                     }
265 283
                     {outputDevices.map((data, i) =>
266
-                        this._renderSpeakerEntry(data, i),
284
+                        this._renderSpeakerEntry(data, i, t),
267 285
                     )}
268 286
                 </div>
269 287
             </div>

Načítá se…
Zrušit
Uložit