Fixes hangup triggering multiple feedbacks.

This commit is contained in:
yanas 2016-08-26 11:41:57 -05:00
parent 2bb637e140
commit 777217bd75
3 changed files with 24 additions and 18 deletions

View File

@ -16,6 +16,8 @@ import mediaDeviceHelper from './modules/devices/mediaDeviceHelper';
import {reportError} from './modules/util/helpers';
import Feedback from './modules/UI/Feedback';
const ConnectionEvents = JitsiMeetJS.events.connection;
const ConnectionErrors = JitsiMeetJS.errors.connection;
@ -37,12 +39,6 @@ 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";
/**
@ -238,25 +234,29 @@ 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();
// 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 === Feedback.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);
});
_hangupInProgress = false;
}
/**

View File

@ -86,10 +86,16 @@ function _showFeedbackButton (show) {
* toggleStars: Function, hoverStars: Function, unhoverStars: Function}}
*/
var Feedback = {
/**
* Indicates a state of the Feedback dialog.
*/
FEEDBACK_REQUEST_IN_PROGRESS: "FeedbackRequestInProgress",
/**
* 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.

View File

@ -1064,7 +1064,7 @@ UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
*/
UI.requestFeedback = function () {
if (Feedback.isVisible())
return Promise.resolve();
return Promise.reject(Feedback.FEEDBACK_REQUEST_IN_PROGRESS);
else
return new Promise(function (resolve, reject) {
if (Feedback.isEnabled()) {