Просмотр исходного кода

Merge pull request #810 from jitsi/fix-hangup-multiple-feedback-windows

Fix hangup triggering multiple feedback windows
j8
hristoterezov 9 лет назад
Родитель
Сommit
f9b3f34593
4 измененных файлов: 65 добавлений и 24 удалений
  1. 18
    3
      conference.js
  2. 12
    0
      modules/UI/Feedback.js
  3. 25
    21
      modules/UI/UI.js
  4. 10
    0
      modules/UI/UIErrors.js

+ 18
- 3
conference.js Просмотреть файл

@@ -16,6 +16,8 @@ import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
16 16
 
17 17
 import {reportError} from './modules/util/helpers';
18 18
 
19
+import UIErrors from './modules/UI/UIErrors';
20
+
19 21
 const ConnectionEvents = JitsiMeetJS.events.connection;
20 22
 const ConnectionErrors = JitsiMeetJS.errors.connection;
21 23
 
@@ -233,15 +235,28 @@ function disconnectAndShowFeedback(requestFeedback) {
233 235
  */
234 236
 function hangup (requestFeedback = false) {
235 237
     const errCallback = (f, err) => {
236
-        console.error('Error occurred during hanging up: ', err);
237
-        return f();
238
+
239
+        // If we want to break out the chain in our error handler, it needs
240
+        // to return a rejected promise. In the case of feedback request
241
+        // in progress it's important to not redirect to the welcome page
242
+        // (see below maybeRedirectToWelcomePage call).
243
+        if (err === UIErrors.FEEDBACK_REQUEST_IN_PROGRESS) {
244
+            return Promise.reject('Feedback request in progress.');
245
+        }
246
+        else {
247
+            console.error('Error occurred during hanging up: ', err);
248
+            return Promise.resolve();
249
+        }
238 250
     };
239 251
     const disconnect = disconnectAndShowFeedback.bind(null, requestFeedback);
240 252
     APP.conference._room.leave()
241 253
     .then(disconnect)
242 254
     .catch(errCallback.bind(null, disconnect))
243 255
     .then(maybeRedirectToWelcomePage)
244
-    .catch(errCallback.bind(null, maybeRedirectToWelcomePage));
256
+    .catch(function(err){
257
+            console.log(err);
258
+        });
259
+
245 260
 }
246 261
 
247 262
 /**

+ 12
- 0
modules/UI/Feedback.js Просмотреть файл

@@ -90,6 +90,7 @@ var Feedback = {
90 90
      * The feedback score. -1 indicates no score has been given for now.
91 91
      */
92 92
     feedbackScore: -1,
93
+
93 94
     /**
94 95
      * Initialise the Feedback functionality.
95 96
      * @param emitter the EventEmitter to associate with the Feedback.
@@ -134,6 +135,17 @@ var Feedback = {
134 135
     isEnabled: function() {
135 136
         return this.enabled && APP.conference.isCallstatsEnabled();
136 137
     },
138
+
139
+    /**
140
+     * Returns true if the feedback window is currently visible and false
141
+     * otherwise.
142
+     * @return {boolean} true if the feedback window is visible, false
143
+     * otherwise
144
+     */
145
+    isVisible: function() {
146
+        return $(".feedback").is(":visible");
147
+    },
148
+
137 149
     /**
138 150
      * Opens the feedback window.
139 151
      */

+ 25
- 21
modules/UI/UI.js Просмотреть файл

@@ -23,6 +23,7 @@ import SettingsMenu from "./side_pannels/settings/SettingsMenu";
23 23
 import Settings from "./../settings/Settings";
24 24
 import { reload } from '../util/helpers';
25 25
 import RingOverlay from "./ring_overlay/RingOverlay";
26
+import UIErrors from './UIErrors';
26 27
 
27 28
 var EventEmitter = require("events");
28 29
 UI.messageHandler = require("./util/MessageHandler");
@@ -1063,29 +1064,32 @@ UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
1063 1064
  * @returns {Promise} when dialog is closed.
1064 1065
  */
1065 1066
 UI.requestFeedback = function () {
1066
-    return new Promise(function (resolve, reject) {
1067
-        if (Feedback.isEnabled()) {
1068
-            // If the user has already entered feedback, we'll show the window and
1069
-            // immidiately start the conference dispose timeout.
1070
-            if (Feedback.feedbackScore > 0) {
1071
-                Feedback.openFeedbackWindow();
1067
+    if (Feedback.isVisible())
1068
+        return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
1069
+    else
1070
+        return new Promise(function (resolve, reject) {
1071
+            if (Feedback.isEnabled()) {
1072
+                // If the user has already entered feedback, we'll show the
1073
+                // window and immidiately start the conference dispose timeout.
1074
+                if (Feedback.feedbackScore > 0) {
1075
+                    Feedback.openFeedbackWindow();
1076
+                    resolve();
1077
+
1078
+                } else { // Otherwise we'll wait for user's feedback.
1079
+                    Feedback.openFeedbackWindow(resolve);
1080
+                }
1081
+            } else {
1082
+                // If the feedback functionality isn't enabled we show a thank
1083
+                // you dialog.
1084
+                messageHandler.openMessageDialog(
1085
+                    null, null, null,
1086
+                    APP.translation.translateString(
1087
+                        "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
1088
+                    )
1089
+                );
1072 1090
                 resolve();
1073
-
1074
-            } else { // Otherwise we'll wait for user's feedback.
1075
-                Feedback.openFeedbackWindow(resolve);
1076 1091
             }
1077
-        } else {
1078
-            // If the feedback functionality isn't enabled we show a thank you
1079
-            // dialog.
1080
-            messageHandler.openMessageDialog(
1081
-                null, null, null,
1082
-                APP.translation.translateString(
1083
-                    "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
1084
-                )
1085
-            );
1086
-            resolve();
1087
-        }
1088
-    });
1092
+        });
1089 1093
 };
1090 1094
 
1091 1095
 UI.updateRecordingState = function (state) {

+ 10
- 0
modules/UI/UIErrors.js Просмотреть файл

@@ -0,0 +1,10 @@
1
+/**
2
+ * A list of all UI errors.
3
+ */
4
+module.exports = {
5
+    /**
6
+     * Indicates that a Feedback request is currently in progress.
7
+     * @type {{FEEDBACK_REQUEST_IN_PROGRESS: string}}
8
+     */
9
+    FEEDBACK_REQUEST_IN_PROGRESS: "FeedbackRequestInProgress"
10
+};

Загрузка…
Отмена
Сохранить