From 2bb637e1400550de237a079ddf333722d88b13e6 Mon Sep 17 00:00:00 2001 From: yanas Date: Tue, 23 Aug 2016 13:53:40 -0500 Subject: [PATCH] Fixes hangup triggering several times --- conference.js | 15 ++++++++++++++ modules/UI/Feedback.js | 11 +++++++++++ modules/UI/UI.js | 45 ++++++++++++++++++++++-------------------- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/conference.js b/conference.js index 8f9b6584e..5ffe27933 100644 --- a/conference.js +++ b/conference.js @@ -37,6 +37,12 @@ let connectionIsInterrupted = false; */ let DSExternalInstallationInProgress = false; +/** + * Indicates whether we have started a hangup process. + * @type {boolean} + */ +let _hangupInProgress = false; + import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo"; /** @@ -232,6 +238,13 @@ function disconnectAndShowFeedback(requestFeedback) { * @param {boolean} [requestFeedback=false] if user feedback should be requested */ function hangup (requestFeedback = false) { + if (_hangupInProgress) { + console.log("Hangup already in progress."); + return; + } + + _hangupInProgress = true; + const errCallback = (f, err) => { console.error('Error occurred during hanging up: ', err); return f(); @@ -242,6 +255,8 @@ function hangup (requestFeedback = false) { .catch(errCallback.bind(null, disconnect)) .then(maybeRedirectToWelcomePage) .catch(errCallback.bind(null, maybeRedirectToWelcomePage)); + + _hangupInProgress = false; } /** diff --git a/modules/UI/Feedback.js b/modules/UI/Feedback.js index 5799bd8b7..39d7f682f 100644 --- a/modules/UI/Feedback.js +++ b/modules/UI/Feedback.js @@ -134,6 +134,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..ec4fc786e 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1063,29 +1063,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.resolve(); + 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) {