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

Fix hangup triggering multiple feedback windows
This commit is contained in:
hristoterezov 2016-08-26 16:30:31 -05:00 committed by GitHub
commit f9b3f34593
4 changed files with 65 additions and 24 deletions

View File

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

View File

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

View File

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

10
modules/UI/UIErrors.js Normal file
View File

@ -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"
};