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

Merge remote-tracking branch 'origin/master'

master
Lyubomir Marinov 9 роки тому
джерело
коміт
ce9fff2a8d
2 змінених файлів з 35 додано та 63 видалено
  1. 26
    59
      conference.js
  2. 9
    4
      modules/UI/avatar/Avatar.js

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

@@ -38,13 +38,6 @@ let connectionIsInterrupted = false;
38 38
  */
39 39
 let DSExternalInstallationInProgress = false;
40 40
 
41
-/**
42
- * Listens whether conference had been left from local user when we are trying
43
- * to navigate away from current page.
44
- * @type {HangupConferenceLeftListener}
45
- */
46
-let conferenceLeftListener = null;
47
-
48 41
 import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";
49 42
 
50 43
 /**
@@ -219,50 +212,6 @@ function maybeRedirectToWelcomePage(showThankYou) {
219 212
     }, 3000);
220 213
 }
221 214
 
222
-
223
-/**
224
- * Listens for CONFERENCE_LEFT event after hangup function has been executed.
225
- */
226
-class HangupConferenceLeftListener {
227
-    /**
228
-     * Creates HangupConferenceLeftListener and start listening for conference
229
-     * left event. On CONFERENCE_LEFT event calls should disconnect the user
230
-     * and maybe show the feedback dialog.
231
-     * @param {boolean} [requestFeedback=false] if user feedback should be
232
-     * requested
233
-     */
234
-    constructor(requestFeedback) {
235
-        this.requestFeedback = requestFeedback;
236
-        room.on(ConferenceEvents.CONFERENCE_LEFT,
237
-            this._handleConferenceLeft.bind(this));
238
-    }
239
-
240
-    /**
241
-     * Handles the conference left event.
242
-     * @private
243
-     */
244
-    _handleConferenceLeft() {
245
-        this._disconnectAndShowFeedback()
246
-            .then(() => {
247
-                APP.API.notifyReadyToClose();
248
-                maybeRedirectToWelcomePage();
249
-            }).catch(console.log);
250
-    }
251
-
252
-    /**
253
-     * Executes connection.disconnect and shows the feedback dialog
254
-     * @returns Promise.
255
-     * @private
256
-     */
257
-    _disconnectAndShowFeedback() {
258
-        APP.UI.hideRingOverLay();
259
-        connection.disconnect();
260
-        APP.API.notifyConferenceLeft(APP.conference.roomName);
261
-        return (this.requestFeedback) ?
262
-            APP.UI.requestFeedback() : Promise.resolve();
263
-    }
264
-}
265
-
266 215
 /**
267 216
  * Create local tracks of specified types.
268 217
  * @param {Object} options
@@ -486,6 +435,17 @@ function sendTokenDataStats() {
486 435
     }
487 436
 }
488 437
 
438
+/**
439
+ * Disconnects the connection.
440
+ * @returns resolved Promise. We need this in order to make the Promise.all
441
+ * call in hangup() to resolve when all operations are finished.
442
+ */
443
+function disconnect() {
444
+    connection.disconnect();
445
+    APP.API.notifyConferenceLeft(APP.conference.roomName);
446
+    return Promise.resolve();
447
+}
448
+
489 449
 /**
490 450
  * Set permanent ptoperties to analytics.
491 451
  * NOTE: Has to be used after JitsiMeetJS.init. otherwise analytics will be
@@ -1784,13 +1744,20 @@ export default {
1784 1744
      * requested
1785 1745
      */
1786 1746
     hangup (requestFeedback = false) {
1787
-        if (!conferenceLeftListener) {
1788
-            conferenceLeftListener
1789
-                = new HangupConferenceLeftListener(requestFeedback);
1790
-        }
1791
-
1792
-        //FIXME: Do something for the use case when we are not receiving
1793
-        // CONFERENCE_LEFT for some reason
1794
-        room.leave();
1747
+        APP.UI.hideRingOverLay();
1748
+        let requestFeedbackPromise = requestFeedback
1749
+                ? APP.UI.requestFeedback().catch(() => Promise.resolve())
1750
+                : Promise.resolve();
1751
+        // All promises are returning Promise.resolve to make Promise.all to
1752
+        // be resolved when both Promises are finished. Otherwise Promise.all
1753
+        // will reject on first rejected Promise and we can redirect the page
1754
+        // before all operations are done.
1755
+        Promise.all([
1756
+            requestFeedbackPromise,
1757
+            room.leave().then(disconnect, disconnect)
1758
+        ]).then(() => {
1759
+            APP.API.notifyReadyToClose();
1760
+            maybeRedirectToWelcomePage();
1761
+        });
1795 1762
     }
1796 1763
 };

+ 9
- 4
modules/UI/avatar/Avatar.js Переглянути файл

@@ -1,4 +1,4 @@
1
-/* global MD5, config, interfaceConfig */
1
+/* global MD5, config, interfaceConfig, APP */
2 2
 
3 3
 let users = {};
4 4
 
@@ -10,6 +10,12 @@ export default {
10 10
      * @param val {string} value to be set
11 11
      */
12 12
     _setUserProp: function (id, prop, val) {
13
+        // FIXME: Fixes the issue with not be able to return avatar for the
14
+        // local user when the conference has been left. Maybe there is beter
15
+        // way to solve it.
16
+        if(APP.conference.isLocalId(id)) {
17
+            id = "local";
18
+        }
13 19
         if(!val || (users[id] && users[id][prop] === val))
14 20
             return;
15 21
         if(!users[id])
@@ -56,9 +62,8 @@ export default {
56 62
             return 'images/avatar2.png';
57 63
         }
58 64
 
59
-        if (!userId) {
60
-            console.error("Get avatar - id is undefined");
61
-            return null;
65
+        if (!userId || APP.conference.isLocalId(userId)) {
66
+            userId = "local";
62 67
         }
63 68
 
64 69
         let avatarId = null;

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