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
 
39
 
40
 let followMeHandler;
40
 let followMeHandler;
41
 
41
 
42
+let deviceErrorDialog;
43
+
42
 const TrackErrors = JitsiMeetJS.errors.track;
44
 const TrackErrors = JitsiMeetJS.errors.track;
43
 
45
 
44
 const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
46
 const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
1267
 
1269
 
1268
     message = `${message}${doNotShowWarningAgainSection}`;
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
         titleMsg,
1277
         titleMsg,
1272
         message,
1278
         message,
1273
         false,
1279
         false,
1283
                         input.prop("checked");
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
      * @param submitFunction function to be called on submit
113
      * @param submitFunction function to be called on submit
114
      * @param loadedFunction function to be called after the prompt is fully
114
      * @param loadedFunction function to be called after the prompt is fully
115
      *        loaded
115
      *        loaded
116
+     * @param closeFunction function to be called on dialog close
116
      */
117
      */
117
     openDialog: function (titleString, msgString, persistent, buttons,
118
     openDialog: function (titleString, msgString, persistent, buttons,
118
-                              submitFunction, loadedFunction) {
119
+                              submitFunction, loadedFunction, closeFunction) {
119
         if (!popupEnabled)
120
         if (!popupEnabled)
120
             return;
121
             return;
121
 
122
 
125
             buttons: buttons,
126
             buttons: buttons,
126
             defaultButton: 1,
127
             defaultButton: 1,
127
             loaded: loadedFunction,
128
             loaded: loadedFunction,
128
-            submit: submitFunction
129
+            submit: submitFunction,
130
+            close: closeFunction
129
         };
131
         };
132
+
130
         if (persistent) {
133
         if (persistent) {
131
             args.closeText = '';
134
             args.closeText = '';
132
         }
135
         }
136
+        
133
         return new Impromptu(msgString, args);
137
         return new Impromptu(msgString, args);
134
     },
138
     },
135
 
139
 

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

194
             return createLocalTracks(
194
             return createLocalTracks(
195
                     ['audio', 'video'], cameraDeviceId, micDeviceId)
195
                     ['audio', 'video'], cameraDeviceId, micDeviceId)
196
                     // If we fail to do this, try to create them separately.
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
                         if (audioTrackError || videoTrackError) {
202
                         if (audioTrackError || videoTrackError) {
201
                             APP.UI.showDeviceErrorDialog(
203
                             APP.UI.showDeviceErrorDialog(
202
                                 audioTrackError, videoTrackError);
204
                                 audioTrackError, videoTrackError);
203
                         }
205
                         }
204
 
206
 
205
-                        return (audioTracks || []).concat(videoTracks || []);
207
+                        return tracks.filter(t => typeof t !== 'undefined');
206
                     });
208
                     });
207
         } else if (videoRequested && !audioRequested) {
209
         } else if (videoRequested && !audioRequested) {
208
             return createVideoTrack();
210
             return createVideoTrack();

Loading…
Cancel
Save