Fixes issue with not working hangup button on FF

This commit is contained in:
hristoterezov 2016-05-05 11:11:05 -05:00
parent 2c0d60a1f4
commit 9dc9dc3685
1 changed files with 38 additions and 19 deletions

View File

@ -121,30 +121,49 @@ function muteLocalVideo (muted) {
} }
} }
/**
* Check if the welcome page is enabled and redirects to it.
*/
function maybeRedirectToWelcomePage() {
if (!config.enableWelcomePage) {
return;
}
// redirect to welcome page
setTimeout(() => {
APP.settings.setWelcomePageEnabled(true);
window.location.pathname = "/";
}, 3000);
}
/**
* Executes connection.disconnect and shows the feedback dialog
* @param {boolean} [requestFeedback=false] if user feedback should be requested
* @returns Promise.
*/
function disconnectAndShowFeedback(requestFeedback) {
connection.disconnect();
if (requestFeedback) {
return APP.UI.requestFeedback();
} else {
return Promise.resolve();
}
}
/** /**
* Disconnect from the conference and optionally request user feedback. * Disconnect from the conference and optionally request user feedback.
* @param {boolean} [requestFeedback=false] if user feedback should be requested * @param {boolean} [requestFeedback=false] if user feedback should be requested
*/ */
function hangup (requestFeedback = false) { function hangup (requestFeedback = false) {
APP.conference._room.leave().then(() => { const errCallback = (f, err) => {
connection.disconnect(); console.error('Error occurred during hanging up: ', err);
if (requestFeedback) { return f();
return APP.UI.requestFeedback(); };
} else { const disconnect = disconnectAndShowFeedback.bind(null, requestFeedback);
return Promise.resolve(); APP.conference._room.leave()
} .then(disconnect)
}).then(function () { .catch(errCallback.bind(null, disconnect))
if (!config.enableWelcomePage) { .then(maybeRedirectToWelcomePage)
return; .catch(errCallback.bind(null, maybeRedirectToWelcomePage));
}
// redirect to welcome page
setTimeout(() => {
APP.settings.setWelcomePageEnabled(true);
window.location.pathname = "/";
}, 3000);
}, function (err) {
console.error('Failed to hangup the call:', err);
});
} }
/** /**