diff --git a/conference.js b/conference.js index 8f9b6584e..a7c7693fe 100644 --- a/conference.js +++ b/conference.js @@ -16,6 +16,8 @@ import mediaDeviceHelper from './modules/devices/mediaDeviceHelper'; import {reportError} from './modules/util/helpers'; +import UIErrors from './modules/UI/UIErrors'; + const ConnectionEvents = JitsiMeetJS.events.connection; const ConnectionErrors = JitsiMeetJS.errors.connection; @@ -233,15 +235,28 @@ function disconnectAndShowFeedback(requestFeedback) { */ function hangup (requestFeedback = false) { const errCallback = (f, err) => { - console.error('Error occurred during hanging up: ', err); - return f(); + + // If we want to break out the chain in our error handler, it needs + // to return a rejected promise. In the case of feedback request + // in progress it's important to not redirect to the welcome page + // (see below maybeRedirectToWelcomePage call). + if (err === UIErrors.FEEDBACK_REQUEST_IN_PROGRESS) { + return Promise.reject('Feedback request in progress.'); + } + else { + console.error('Error occurred during hanging up: ', err); + return Promise.resolve(); + } }; const disconnect = disconnectAndShowFeedback.bind(null, requestFeedback); APP.conference._room.leave() .then(disconnect) .catch(errCallback.bind(null, disconnect)) .then(maybeRedirectToWelcomePage) - .catch(errCallback.bind(null, maybeRedirectToWelcomePage)); + .catch(function(err){ + console.log(err); + }); + } /** diff --git a/modules/UI/Feedback.js b/modules/UI/Feedback.js index 5799bd8b7..90023e77a 100644 --- a/modules/UI/Feedback.js +++ b/modules/UI/Feedback.js @@ -90,6 +90,7 @@ var Feedback = { * The feedback score. -1 indicates no score has been given for now. */ feedbackScore: -1, + /** * Initialise the Feedback functionality. * @param emitter the EventEmitter to associate with the Feedback. @@ -134,6 +135,17 @@ var Feedback = { isEnabled: function() { return this.enabled && APP.conference.isCallstatsEnabled(); }, + + /** + * Returns true if the feedback window is currently visible and false + * otherwise. + * @return {boolean} true if the feedback window is visible, false + * otherwise + */ + isVisible: function() { + return $(".feedback").is(":visible"); + }, + /** * Opens the feedback window. */ diff --git a/modules/UI/UI.js b/modules/UI/UI.js index e57fe2251..fc0565d9a 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -23,6 +23,7 @@ import SettingsMenu from "./side_pannels/settings/SettingsMenu"; import Settings from "./../settings/Settings"; import { reload } from '../util/helpers'; import RingOverlay from "./ring_overlay/RingOverlay"; +import UIErrors from './UIErrors'; var EventEmitter = require("events"); UI.messageHandler = require("./util/MessageHandler"); @@ -1063,29 +1064,32 @@ UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) { * @returns {Promise} when dialog is closed. */ UI.requestFeedback = function () { - return new Promise(function (resolve, reject) { - if (Feedback.isEnabled()) { - // If the user has already entered feedback, we'll show the window and - // immidiately start the conference dispose timeout. - if (Feedback.feedbackScore > 0) { - Feedback.openFeedbackWindow(); - resolve(); + if (Feedback.isVisible()) + return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS); + else + return new Promise(function (resolve, reject) { + if (Feedback.isEnabled()) { + // If the user has already entered feedback, we'll show the + // window and immidiately start the conference dispose timeout. + if (Feedback.feedbackScore > 0) { + Feedback.openFeedbackWindow(); + resolve(); - } else { // Otherwise we'll wait for user's feedback. - Feedback.openFeedbackWindow(resolve); + } else { // Otherwise we'll wait for user's feedback. + Feedback.openFeedbackWindow(resolve); + } + } else { + // If the feedback functionality isn't enabled we show a thank + // you dialog. + messageHandler.openMessageDialog( + null, null, null, + APP.translation.translateString( + "dialog.thankYou", {appName:interfaceConfig.APP_NAME} + ) + ); + resolve(); } - } else { - // If the feedback functionality isn't enabled we show a thank you - // dialog. - messageHandler.openMessageDialog( - null, null, null, - APP.translation.translateString( - "dialog.thankYou", {appName:interfaceConfig.APP_NAME} - ) - ); - resolve(); - } - }); + }); }; UI.updateRecordingState = function (state) { diff --git a/modules/UI/UIErrors.js b/modules/UI/UIErrors.js new file mode 100644 index 000000000..b6c6310c7 --- /dev/null +++ b/modules/UI/UIErrors.js @@ -0,0 +1,10 @@ +/** + * A list of all UI errors. + */ +module.exports = { + /** + * Indicates that a Feedback request is currently in progress. + * @type {{FEEDBACK_REQUEST_IN_PROGRESS: string}} + */ + FEEDBACK_REQUEST_IN_PROGRESS: "FeedbackRequestInProgress" +}; \ No newline at end of file