Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

actions.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors';
  2. import { openDialog } from '../../features/base/dialog';
  3. import {
  4. CANCEL_FEEDBACK,
  5. SUBMIT_FEEDBACK
  6. } from './actionTypes';
  7. import { FeedbackDialog } from './components';
  8. declare var config: Object;
  9. declare var interfaceConfig: Object;
  10. /**
  11. * Caches the passed in feedback in the redux store.
  12. *
  13. * @param {number} score - The quality score given to the conference.
  14. * @param {string} message - A description entered by the participant that
  15. * explains the rating.
  16. * @returns {{
  17. * type: CANCEL_FEEDBACK,
  18. * message: string,
  19. * score: number
  20. * }}
  21. */
  22. export function cancelFeedback(score, message) {
  23. return {
  24. type: CANCEL_FEEDBACK,
  25. message,
  26. score
  27. };
  28. }
  29. /**
  30. * Potentially open the {@code FeedbackDialog}. It will not be opened if it is
  31. * already open or feedback has already been submitted.
  32. *
  33. * @param {JistiConference} conference - The conference for which the feedback
  34. * would be about. The conference is passed in because feedback can occur after
  35. * a conference has been left, so references to it may no longer exist in redux.
  36. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  37. * resolved with true if the dialog is disabled or the feedback was already
  38. * submitted. Rejected if another dialog is already displayed.
  39. */
  40. export function maybeOpenFeedbackDialog(conference) {
  41. return (dispatch, getState) => {
  42. const state = getState();
  43. if (interfaceConfig.filmStripOnly || config.iAmRecorder) {
  44. // Intentionally fall through the if chain to prevent further action
  45. // from being taken with regards to showing feedback.
  46. } else if (state['features/base/dialog'].component === FeedbackDialog) {
  47. // Feedback is currently being displayed.
  48. return Promise.reject(FEEDBACK_REQUEST_IN_PROGRESS);
  49. } else if (state['features/feedback'].submitted) {
  50. // Feedback has been submitted already.
  51. return Promise.resolve({
  52. thankYouDialogVisible: true,
  53. feedbackSubmitted: true
  54. });
  55. } else if (conference.isCallstatsEnabled()) {
  56. return new Promise(resolve => {
  57. dispatch(openFeedbackDialog(conference, () => {
  58. const { submitted } = getState()['features/feedback'];
  59. resolve({
  60. feedbackSubmitted: submitted,
  61. thankYouDialogVisible: false
  62. });
  63. }));
  64. });
  65. }
  66. // If the feedback functionality isn't enabled we show a thank
  67. // you dialog. Signaling it (true), so the caller
  68. // of requestFeedback can act on it
  69. return Promise.resolve({
  70. thankYouDialogVisible: true,
  71. feedbackSubmitted: false
  72. });
  73. };
  74. }
  75. /**
  76. * Opens {@code FeedbackDialog}.
  77. *
  78. * @param {JitsiConference} conference - The JitsiConference that is being
  79. * rated. The conference is passed in because feedback can occur after a
  80. * conference has been left, so references to it may no longer exist in redux.
  81. * @param {Function} [onClose] - An optional callback to invoke when the dialog
  82. * is closed.
  83. * @returns {Object}
  84. */
  85. export function openFeedbackDialog(conference, onClose) {
  86. return openDialog(FeedbackDialog, {
  87. conference,
  88. onClose
  89. });
  90. }
  91. /**
  92. * Send the passed in feedback.
  93. *
  94. * @param {number} score - An integer between 1 and 5 indicating the user
  95. * feedback. The negative integer -1 is used to denote no score was selected.
  96. * @param {string} message - Detailed feedback from the user to explain the
  97. * rating.
  98. * @param {JitsiConference} conference - The JitsiConference for which the
  99. * feedback is being left.
  100. * @returns {{
  101. * type: SUBMIT_FEEDBACK
  102. * }}
  103. */
  104. export function submitFeedback(score, message, conference) {
  105. conference.sendFeedback(score, message);
  106. return {
  107. type: SUBMIT_FEEDBACK
  108. };
  109. }