Merge pull request #2401 from virtuacoplenny/lenny/spot-feedback-api

feat(api): expose a way to submit feedback
This commit is contained in:
Emil Ivov 2018-01-19 16:57:18 -06:00 committed by GitHub
commit 22401614a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 1 deletions

View File

@ -91,7 +91,10 @@ import {
import { statsEmitter } from './react/features/connection-indicator';
import { showDesktopPicker } from './react/features/desktop-picker';
import { appendSuffix } from './react/features/display-name';
import { maybeOpenFeedbackDialog } from './react/features/feedback';
import {
maybeOpenFeedbackDialog,
submitFeedback
} from './react/features/feedback';
import {
mediaPermissionPromptVisibilityChanged,
suspendDetected
@ -2798,5 +2801,21 @@ export default {
setAudioMuteStatus(muted) {
APP.UI.setAudioMuted(this.getMyUserId(), muted);
APP.API.notifyAudioMutedStatusChanged(muted);
},
/**
* Dispatches the passed in feedback for submission. The submitted score
* should be a number inclusively between 1 through 5, or -1 for no score.
*
* @param {number} score - a number between 1 and 5 (inclusive) or -1 for no
* score.
* @param {string} message - An optional message to attach to the feedback
* in addition to the score.
* @returns {void}
*/
submitFeedback(score = -1, message = '') {
if (score === -1 || (score >= 1 && score <= 5)) {
APP.store.dispatch(submitFeedback(score, message, room));
}
}
};

View File

@ -59,6 +59,10 @@ function initCommands() {
sendAnalytics(createApiEvent('display.name.changed'));
APP.conference.changeLocalDisplayName(displayName);
},
'submit-feedback': feedback => {
sendAnalytics(createApiEvent('submit.feedback'));
APP.conference.submitFeedback(feedback.score, feedback.message);
},
'toggle-audio': () => {
sendAnalytics(createApiEvent('toggle-audio'));
logger.log('Audio toggle: API command received');
@ -456,6 +460,16 @@ class API {
});
}
/**
* Notify external application (if API is enabled) that conference feedback
* has been submitted. Intended to be used in conjunction with the
* submit-feedback command to get notified if feedback was submitted.
*
* @returns {void}
*/
notifyFeedbackSubmitted() {
this._sendEvent({ name: 'feedback-submitted' });
}
/**
* Disposes the allocated resources.

View File

@ -21,6 +21,7 @@ const commands = {
displayName: 'display-name',
email: 'email',
hangup: 'video-hangup',
submitFeedback: 'submit-feedback',
toggleAudio: 'toggle-audio',
toggleChat: 'toggle-chat',
toggleContactList: 'toggle-contact-list',
@ -38,6 +39,7 @@ const events = {
'audio-availability-changed': 'audioAvailabilityChanged',
'audio-mute-status-changed': 'audioMuteStatusChanged',
'display-name-change': 'displayNameChange',
'feedback-submitted': 'feedbackSubmitted',
'incoming-message': 'incomingMessage',
'outgoing-message': 'outgoingMessage',
'participant-joined': 'participantJoined',

View File

@ -2,4 +2,5 @@ export * from './actions';
export * from './actionTypes';
export * from './components';
import './middleware';
import './reducer';

View File

@ -0,0 +1,26 @@
/* @flow */
import { MiddlewareRegistry } from '../base/redux';
import { SUBMIT_FEEDBACK } from './actionTypes';
declare var APP: Object;
/**
* Implements the middleware of the feature feedback.
*
* @param {Store} store - The redux store.
* @returns {Function}
*/
// eslint-disable-next-line no-unused-vars
MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
case SUBMIT_FEEDBACK:
if (typeof APP === 'object') {
APP.API.notifyFeedbackSubmitted();
}
break;
}
return next(action);
});