Browse Source

Merge pull request #697 from tsareg/fix_two_gum_error_dialogs

Fixing various edge-cases when two gUM error dialogs might be shown and other possible bugs
j8
Любомир Маринов 9 years ago
parent
commit
1f942aa13d
3 changed files with 25 additions and 7 deletions
  1. 13
    1
      modules/UI/UI.js
  2. 6
    2
      modules/UI/util/MessageHandler.js
  3. 6
    4
      modules/devices/mediaDeviceHelper.js

+ 13
- 1
modules/UI/UI.js View File

@@ -39,6 +39,8 @@ let sharedVideoManager;
39 39
 
40 40
 let followMeHandler;
41 41
 
42
+let deviceErrorDialog;
43
+
42 44
 const TrackErrors = JitsiMeetJS.errors.track;
43 45
 
44 46
 const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
@@ -1267,7 +1269,11 @@ UI.showDeviceErrorDialog = function (micError, cameraError) {
1267 1269
 
1268 1270
     message = `${message}${doNotShowWarningAgainSection}`;
1269 1271
 
1270
-    messageHandler.openDialog(
1272
+    // To make sure we don't have multiple error dialogs open at the same time,
1273
+    // we will just close the previous one if we are going to show a new one.
1274
+    deviceErrorDialog && deviceErrorDialog.close();
1275
+
1276
+    deviceErrorDialog = messageHandler.openDialog(
1271 1277
         titleMsg,
1272 1278
         message,
1273 1279
         false,
@@ -1283,6 +1289,12 @@ UI.showDeviceErrorDialog = function (micError, cameraError) {
1283 1289
                         input.prop("checked");
1284 1290
                 }
1285 1291
             }
1292
+        },
1293
+        null,
1294
+        function () {
1295
+            // Reset dialog reference to null to avoid memory leaks when
1296
+            // user closed the dialog manually.
1297
+            deviceErrorDialog = null;
1286 1298
         }
1287 1299
     );
1288 1300
 

+ 6
- 2
modules/UI/util/MessageHandler.js View File

@@ -113,9 +113,10 @@ var messageHandler = {
113 113
      * @param submitFunction function to be called on submit
114 114
      * @param loadedFunction function to be called after the prompt is fully
115 115
      *        loaded
116
+     * @param closeFunction function to be called on dialog close
116 117
      */
117 118
     openDialog: function (titleString, msgString, persistent, buttons,
118
-                              submitFunction, loadedFunction) {
119
+                              submitFunction, loadedFunction, closeFunction) {
119 120
         if (!popupEnabled)
120 121
             return;
121 122
 
@@ -125,11 +126,14 @@ var messageHandler = {
125 126
             buttons: buttons,
126 127
             defaultButton: 1,
127 128
             loaded: loadedFunction,
128
-            submit: submitFunction
129
+            submit: submitFunction,
130
+            close: closeFunction
129 131
         };
132
+
130 133
         if (persistent) {
131 134
             args.closeText = '';
132 135
         }
136
+        
133 137
         return new Impromptu(msgString, args);
134 138
     },
135 139
 

+ 6
- 4
modules/devices/mediaDeviceHelper.js View File

@@ -194,15 +194,17 @@ export default {
194 194
             return createLocalTracks(
195 195
                     ['audio', 'video'], cameraDeviceId, micDeviceId)
196 196
                     // If we fail to do this, try to create them separately.
197
-                    .catch(() => Promise.all(
198
-                        [createAudioTrack(false), createVideoTrack(false)]))
199
-                    .then((audioTracks, videoTracks) => {
197
+                    .catch(() => Promise.all([
198
+                        createAudioTrack(false).then(([stream]) => stream),
199
+                        createVideoTrack(false).then(([stream]) => stream)
200
+                    ]))
201
+                    .then(tracks => {
200 202
                         if (audioTrackError || videoTrackError) {
201 203
                             APP.UI.showDeviceErrorDialog(
202 204
                                 audioTrackError, videoTrackError);
203 205
                         }
204 206
 
205
-                        return (audioTracks || []).concat(videoTracks || []);
207
+                        return tracks.filter(t => typeof t !== 'undefined');
206 208
                     });
207 209
         } else if (videoRequested && !audioRequested) {
208 210
             return createVideoTrack();

Loading…
Cancel
Save