Fixes hangup triggering several times

This commit is contained in:
yanas 2016-08-23 13:53:40 -05:00
parent b5c1c95a15
commit 2bb637e140
3 changed files with 50 additions and 21 deletions

View File

@ -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;
}
/**

View File

@ -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.
*/

View File

@ -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) {