From 732f2c19633128f2c3784d93ae9a445088e80daa Mon Sep 17 00:00:00 2001 From: virtuacoplenny <1243084+virtuacoplenny@users.noreply.github.com> Date: Wed, 31 Jul 2019 10:59:22 -0700 Subject: [PATCH] ref(feedback): emit api feedback submitted on completion (#4499) * ref(feedback): emit api feedback submitted on completion Compared to firing the event on submission because the submission ajax will not be completed at that time.. * squash: update package.json --- doc/api.md | 7 +++++++ modules/API/API.js | 8 ++++++-- package-lock.json | 4 ++-- package.json | 2 +- react/features/external-api/middleware.js | 8 ++++++-- react/features/feedback/actionTypes.js | 18 +++++++++++----- react/features/feedback/actions.js | 25 +++++++++++++++-------- react/features/feedback/reducer.js | 6 ++++-- 8 files changed, 56 insertions(+), 22 deletions(-) diff --git a/doc/api.md b/doc/api.md index 1cd8e9ecd..b9c0606c8 100644 --- a/doc/api.md +++ b/doc/api.md @@ -372,6 +372,13 @@ changes. The listener will receive an object with the following structure: email: string // the new email } ``` +* **feedbackSubmitted** - event notifications about conference feedback submission +```javascript +{ + error: string // The error which occurred during submission, if any. +} +``` + * **filmstripDisplayChanged** - event notifications about the visibility of the filmstrip being updated. ```javascript { diff --git a/modules/API/API.js b/modules/API/API.js index 2ef9effd4..1804a92a6 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -627,10 +627,14 @@ class API { * has been submitted. Intended to be used in conjunction with the * submit-feedback command to get notified if feedback was submitted. * + * @param {string} error - A failure message, if any. * @returns {void} */ - notifyFeedbackSubmitted() { - this._sendEvent({ name: 'feedback-submitted' }); + notifyFeedbackSubmitted(error: string) { + this._sendEvent({ + name: 'feedback-submitted', + error + }); } /** diff --git a/package-lock.json b/package-lock.json index 310d3be7e..771b0bb0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9073,8 +9073,8 @@ } }, "lib-jitsi-meet": { - "version": "github:jitsi/lib-jitsi-meet#502ba82e1e4e4cdf8fe768566b6414f5c100491a", - "from": "github:jitsi/lib-jitsi-meet#502ba82e1e4e4cdf8fe768566b6414f5c100491a", + "version": "github:jitsi/lib-jitsi-meet#97475026de59442f9b8a50d5abed6131a0b1c544", + "from": "github:jitsi/lib-jitsi-meet#97475026de59442f9b8a50d5abed6131a0b1c544", "requires": { "@jitsi/sdp-interop": "0.1.14", "@jitsi/sdp-simulcast": "0.2.1", diff --git a/package.json b/package.json index 35b127d46..13394a446 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "js-utils": "github:jitsi/js-utils#192b1c996e8c05530eb1f19e82a31069c3021e31", "jsrsasign": "8.0.12", "jwt-decode": "2.2.0", - "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#502ba82e1e4e4cdf8fe768566b6414f5c100491a", + "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#97475026de59442f9b8a50d5abed6131a0b1c544", "libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d", "lodash": "4.17.11", "moment": "2.19.4", diff --git a/react/features/external-api/middleware.js b/react/features/external-api/middleware.js index 2e433bd58..19bef1907 100644 --- a/react/features/external-api/middleware.js +++ b/react/features/external-api/middleware.js @@ -18,7 +18,7 @@ import { import { MiddlewareRegistry } from '../base/redux'; import { getBaseUrl } from '../base/util'; import { appendSuffix } from '../display-name'; -import { SUBMIT_FEEDBACK } from '../feedback'; +import { SUBMIT_FEEDBACK_ERROR, SUBMIT_FEEDBACK_SUCCESS } from '../feedback'; import { SET_FILMSTRIP_VISIBLE } from '../filmstrip'; declare var APP: Object; @@ -156,7 +156,11 @@ MiddlewareRegistry.register(store => next => action => { APP.API.notifyFilmstripDisplayChanged(action.visible); break; - case SUBMIT_FEEDBACK: + case SUBMIT_FEEDBACK_ERROR: + APP.API.notifyFeedbackSubmitted(action.error || 'Unknown error'); + break; + + case SUBMIT_FEEDBACK_SUCCESS: APP.API.notifyFeedbackSubmitted(); break; } diff --git a/react/features/feedback/actionTypes.js b/react/features/feedback/actionTypes.js index a5dc7e681..98d7292d9 100644 --- a/react/features/feedback/actionTypes.js +++ b/react/features/feedback/actionTypes.js @@ -10,12 +10,20 @@ export const CANCEL_FEEDBACK = 'CANCEL_FEEDBACK'; /** - * The type of the action which signals feedback was submitted for recording. + * The type of the action which signals feedback failed to be recorded. * * { - * type: SUBMIT_FEEDBACK, - * message: string, - * score: number + * type: SUBMIT_FEEDBACK_ERROR + * error: string * } */ -export const SUBMIT_FEEDBACK = 'SUBMIT_FEEDBACK'; +export const SUBMIT_FEEDBACK_ERROR = 'SUBMIT_FEEDBACK_ERROR'; + +/** + * The type of the action which signals feedback has been recorded. + * + * { + * type: SUBMIT_FEEDBACK_SUCCESS, + * } + */ +export const SUBMIT_FEEDBACK_SUCCESS = 'SUBMIT_FEEDBACK_SUCCESS'; diff --git a/react/features/feedback/actions.js b/react/features/feedback/actions.js index 417bf42b3..52c9dc82a 100644 --- a/react/features/feedback/actions.js +++ b/react/features/feedback/actions.js @@ -5,7 +5,11 @@ import type { Dispatch } from 'redux'; import { openDialog } from '../base/dialog'; import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors'; -import { CANCEL_FEEDBACK, SUBMIT_FEEDBACK } from './actionTypes'; +import { + CANCEL_FEEDBACK, + SUBMIT_FEEDBACK_ERROR, + SUBMIT_FEEDBACK_SUCCESS +} from './actionTypes'; import { FeedbackDialog } from './components'; declare var config: Object; @@ -114,17 +118,22 @@ export function openFeedbackDialog(conference: Object, onClose: ?Function) { * rating. * @param {JitsiConference} conference - The JitsiConference for which the * feedback is being left. - * @returns {{ - * type: SUBMIT_FEEDBACK - * }} + * @returns {Function} */ export function submitFeedback( score: number, message: string, conference: Object) { - conference.sendFeedback(score, message); + return (dispatch: Dispatch) => conference.sendFeedback(score, message) + .then( + () => dispatch({ type: SUBMIT_FEEDBACK_SUCCESS }), + error => { + dispatch({ + type: SUBMIT_FEEDBACK_ERROR, + error + }); - return { - type: SUBMIT_FEEDBACK - }; + return Promise.reject(error); + } + ); } diff --git a/react/features/feedback/reducer.js b/react/features/feedback/reducer.js index b8cddbac5..63e6f9fc6 100644 --- a/react/features/feedback/reducer.js +++ b/react/features/feedback/reducer.js @@ -4,7 +4,8 @@ import { import { CANCEL_FEEDBACK, - SUBMIT_FEEDBACK + SUBMIT_FEEDBACK_ERROR, + SUBMIT_FEEDBACK_SUCCESS } from './actionTypes'; const DEFAULT_STATE = { @@ -31,7 +32,8 @@ ReducerRegistry.register( }; } - case SUBMIT_FEEDBACK: { + case SUBMIT_FEEDBACK_ERROR: + case SUBMIT_FEEDBACK_SUCCESS: { return { ...state, message: '',