Переглянути джерело

fix: open device selection if it is the only available setting

Move logic to open device selection outside of SettingsMenu so
it can be called independently by either SettingsMenu or by
the settings button itself if no other settings but devices will
be displayed.
j8
Leonard Kim 8 роки тому
джерело
коміт
7db1c9b8eb

+ 0
- 17
conference.js Переглянути файл

@@ -1058,15 +1058,6 @@ export default {
1058 1058
             });
1059 1059
     },
1060 1060
 
1061
-    /**
1062
-     * Returns the current local video track in use.
1063
-     *
1064
-     * @returns {JitsiLocalTrack}
1065
-     */
1066
-    getLocalVideoTrack() {
1067
-        return room.getLocalVideoTrack();
1068
-    },
1069
-
1070 1061
     /**
1071 1062
      * Start using provided audio stream.
1072 1063
      * Stops previous audio stream.
@@ -1096,14 +1087,6 @@ export default {
1096 1087
             });
1097 1088
     },
1098 1089
 
1099
-    /**
1100
-     * Returns the current local audio track in use.
1101
-     *
1102
-     * @returns {JitsiLocalTrack}
1103
-     */
1104
-    getLocalAudioTrack() {
1105
-        return room.getLocalAudioTrack();
1106
-    },
1107 1090
 
1108 1091
     videoSwitchInProgress: false,
1109 1092
     toggleScreenSharing(shareScreen = !this.isSharingScreen) {

+ 15
- 1
modules/UI/UI.js Переглянути файл

@@ -31,6 +31,9 @@ import {
31 31
     setAudioMuted,
32 32
     setVideoMuted
33 33
 } from '../../react/features/base/media';
34
+import {
35
+    openDeviceSelectionDialog
36
+} from '../../react/features/device-selection';
34 37
 import {
35 38
     checkAutoEnableDesktopSharing,
36 39
     dockToolbox,
@@ -1369,7 +1372,18 @@ const UIListeners = new Map([
1369 1372
         UI.toggleChat
1370 1373
     ], [
1371 1374
         UIEvents.TOGGLE_SETTINGS,
1372
-        () => UI.toggleSidePanel("settings_container")
1375
+        () => {
1376
+            // Opening of device selection is special-cased as it is a dialog
1377
+            // opened through a button in settings and not directly displayed in
1378
+            // settings itself. As it is not useful to only have a settings menu
1379
+            // with a button to open a dialog, open the dialog directly instead.
1380
+            if (interfaceConfig.SETTINGS_SECTIONS.length === 1
1381
+                    && UIUtil.isSettingEnabled('devices')) {
1382
+                APP.store.dispatch(openDeviceSelectionDialog());
1383
+            } else {
1384
+                UI.toggleSidePanel("settings_container");
1385
+            }
1386
+        }
1373 1387
     ], [
1374 1388
         UIEvents.TOGGLE_CONTACT_LIST,
1375 1389
         UI.toggleContactList

+ 4
- 37
modules/UI/side_pannels/settings/SettingsMenu.js Переглянути файл

@@ -1,7 +1,6 @@
1
-/* global $, APP, AJS, interfaceConfig, JitsiMeetJS */
2
-import { openDialog } from '../../../../react/features/base/dialog';
1
+/* global $, APP, AJS, interfaceConfig */
3 2
 import { LANGUAGES } from "../../../../react/features/base/i18n";
4
-import { DeviceSelectionDialog }
3
+import { openDeviceSelectionDialog }
5 4
     from '../../../../react/features/device-selection';
6 5
 
7 6
 import UIUtil from "../../util/UIUtil";
@@ -101,34 +100,6 @@ function initSelect2($el, onSelectedCb) {
101 100
     }
102 101
 }
103 102
 
104
-/**
105
- * Open DeviceSelectionDialog with a configuration based on the environment's
106
- * supported abilities.
107
- *
108
- * @param {boolean} isDeviceListAvailable - Whether or not device enumeration
109
- * is possible. This is a value obtained through an async operation whereas all
110
- * other configurations for the modal are obtained synchronously.
111
- * @private
112
- * @returns {void}
113
- */
114
-function _openDeviceSelectionModal(isDeviceListAvailable) {
115
-    APP.store.dispatch(openDialog(DeviceSelectionDialog, {
116
-        currentAudioOutputId: APP.settings.getAudioOutputDeviceId(),
117
-        currentAudioTrack: APP.conference.getLocalAudioTrack(),
118
-        currentVideoTrack: APP.conference.getLocalVideoTrack(),
119
-        disableAudioInputChange: !JitsiMeetJS.isMultipleAudioInputSupported(),
120
-        disableDeviceChange: !isDeviceListAvailable
121
-            || !JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
122
-        hasAudioPermission: JitsiMeetJS.mediaDevices
123
-            .isDevicePermissionGranted('audio'),
124
-        hasVideoPermission: JitsiMeetJS.mediaDevices
125
-            .isDevicePermissionGranted('video'),
126
-        hideAudioInputPreview: !JitsiMeetJS.isCollectingLocalStats(),
127
-        hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
128
-            .isDeviceChangeAvailable('output')
129
-    }));
130
-}
131
-
132 103
 export default {
133 104
     init (emitter) {
134 105
         initHTML();
@@ -170,12 +141,8 @@ export default {
170 141
         if (UIUtil.isSettingEnabled('devices')) {
171 142
             const wrapperId = 'deviceOptionsWrapper';
172 143
 
173
-            JitsiMeetJS.mediaDevices.isDeviceListAvailable()
174
-                .then((isDeviceListAvailable) => {
175
-                    $('#deviceSelection').on('click', () => {
176
-                        _openDeviceSelectionModal(isDeviceListAvailable);
177
-                    });
178
-                });
144
+            $('#deviceSelection').on('click', () =>
145
+                APP.store.dispatch(openDeviceSelectionDialog()));
179 146
 
180 147
             // Only show the subtitle if this isn't the only setting section.
181 148
             if (interfaceConfig.SETTINGS_SECTIONS.length > 1)

+ 40
- 0
react/features/device-selection/actions.js Переглянути файл

@@ -0,0 +1,40 @@
1
+/* globals APP */
2
+
3
+import { openDialog } from '../base/dialog';
4
+import JitsiMeetJS from '../base/lib-jitsi-meet';
5
+
6
+import { DeviceSelectionDialog } from './components';
7
+
8
+/**
9
+ * Open DeviceSelectionDialog with a configuration based on the environment's
10
+ * supported abilities.
11
+ *
12
+ * @returns {Function}
13
+ */
14
+export function openDeviceSelectionDialog() {
15
+    return (dispatch, getState) => {
16
+        JitsiMeetJS.mediaDevices.isDeviceListAvailable()
17
+            .then(isDeviceListAvailable => {
18
+                const state = getState();
19
+                const conference = state['features/base/conference'].conference;
20
+
21
+                dispatch(openDialog(DeviceSelectionDialog, {
22
+                    currentAudioOutputId: APP.settings.getAudioOutputDeviceId(),
23
+                    currentAudioTrack: conference.getLocalAudioTrack(),
24
+                    currentVideoTrack: conference.getLocalVideoTrack(),
25
+                    disableAudioInputChange:
26
+                        !JitsiMeetJS.isMultipleAudioInputSupported(),
27
+                    disableDeviceChange: !isDeviceListAvailable
28
+                        || !JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
29
+                    hasAudioPermission: JitsiMeetJS.mediaDevices
30
+                        .isDevicePermissionGranted('audio'),
31
+                    hasVideoPermission: JitsiMeetJS.mediaDevices
32
+                        .isDevicePermissionGranted('video'),
33
+                    hideAudioInputPreview:
34
+                        !JitsiMeetJS.isCollectingLocalStats(),
35
+                    hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
36
+                        .isDeviceChangeAvailable('output')
37
+                }));
38
+            });
39
+    };
40
+}

+ 1
- 0
react/features/device-selection/index.js Переглянути файл

@@ -1 +1,2 @@
1
+export * from './actions';
1 2
 export * from './components';

Завантаження…
Відмінити
Зберегти