From 3022754f19cde485728957714f3ecb984827fd57 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Thu, 20 Oct 2016 14:19:55 -0500 Subject: [PATCH] fix(feedback): Fixes the logic for the thank you dialog --- conference.js | 11 +++++++---- modules/UI/UI.js | 17 +++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/conference.js b/conference.js index cd2eef4c2..f617d16cb 100644 --- a/conference.js +++ b/conference.js @@ -1748,8 +1748,11 @@ export default { hangup (requestFeedback = false) { APP.UI.hideRingOverLay(); let requestFeedbackPromise = requestFeedback - ? APP.UI.requestFeedback().catch(() => Promise.resolve()) - : Promise.resolve(); + ? APP.UI.requestFeedbackOnHangup() + // false - because the thank you dialog shouldn't be displayed + .catch(() => Promise.resolve(false)) + : Promise.resolve(true);// true - because the thank you dialog + //should be displayed // All promises are returning Promise.resolve to make Promise.all to // be resolved when both Promises are finished. Otherwise Promise.all // will reject on first rejected Promise and we can redirect the page @@ -1757,9 +1760,9 @@ export default { Promise.all([ requestFeedbackPromise, room.leave().then(disconnect, disconnect) - ]).then(() => { + ]).then(values => { APP.API.notifyReadyToClose(); - maybeRedirectToWelcomePage(); + maybeRedirectToWelcomePage(values[0]); }); } }; diff --git a/modules/UI/UI.js b/modules/UI/UI.js index a8f542d01..2f005197b 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1061,15 +1061,20 @@ UI.updateDTMFSupport = function (isDTMFSupported) { }; /** - * Show user feedback dialog if its required or just show "thank you" dialog. - * @returns {Promise} when dialog is closed. + * Show user feedback dialog if its required and enabled after pressing the + * hangup button. + * @returns {Promise} Resolved with value - false if the dialog is enabled and + * resolved with true if the dialog is disabled or the feedback was already + * submitted. Rejected if another dialog is already displayed. This values are + * used to display or not display the thank you dialog from + * conference.maybeRedirectToWelcomePage method. */ -UI.requestFeedback = function () { +UI.requestFeedbackOnHangup = function () { if (Feedback.isVisible()) return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS); // Feedback has been submitted already. else if (Feedback.isEnabled() && Feedback.isSubmitted()) - return Promise.resolve(); + return Promise.resolve(true); else return new Promise(function (resolve) { if (Feedback.isEnabled()) { @@ -1077,10 +1082,10 @@ UI.requestFeedback = function () { // window and immidiately start the conference dispose timeout. if (Feedback.getFeedbackScore() > 0) { Feedback.openFeedbackWindow(); - resolve(); + resolve(false); } else { // Otherwise we'll wait for user's feedback. - Feedback.openFeedbackWindow(resolve); + Feedback.openFeedbackWindow(() => resolve(false)); } } else { // If the feedback functionality isn't enabled we show a thank