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

actions.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // @flow
  2. import {
  3. SET_INFO_DIALOG_VISIBILITY,
  4. UPDATE_DIAL_IN_NUMBERS_FAILED,
  5. UPDATE_DIAL_IN_NUMBERS_SUCCESS
  6. } from './actionTypes';
  7. import { getDialInConferenceID, getDialInNumbers } from './functions';
  8. /**
  9. * Opens the inline conference info dialog.
  10. *
  11. * @param {boolean} visible - Whether or not the dialog should be displayed.
  12. * @param {boolean} autoClose - Whether or not the dialog should automatically
  13. * close after a set period of time.
  14. * @returns {{
  15. * type: SET_INFO_DIALOG_VISIBILITY,
  16. * autoClose: boolean,
  17. * visible: boolean
  18. * }}
  19. */
  20. export function setInfoDialogVisibility(
  21. visible: boolean,
  22. autoClose: boolean = false) {
  23. return {
  24. type: SET_INFO_DIALOG_VISIBILITY,
  25. autoClose,
  26. visible
  27. };
  28. }
  29. /**
  30. * Sends AJAX requests for dial-in numbers and conference ID.
  31. *
  32. * @returns {Function}
  33. */
  34. export function updateDialInNumbers() {
  35. return (dispatch: Dispatch<*>, getState: Function) => {
  36. const state = getState();
  37. const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
  38. = state['features/base/config'];
  39. const mucURL = hosts && hosts.muc;
  40. if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
  41. // URLs for fetching dial in numbers not defined
  42. return;
  43. }
  44. const { room } = state['features/base/conference'];
  45. Promise.all([
  46. getDialInNumbers(dialInNumbersUrl),
  47. getDialInConferenceID(dialInConfCodeUrl, room, mucURL)
  48. ])
  49. .then(([ dialInNumbers, { conference, id, message } ]) => {
  50. if (!conference || !id) {
  51. return Promise.reject(message);
  52. }
  53. dispatch({
  54. type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
  55. conferenceID: id,
  56. dialInNumbers
  57. });
  58. })
  59. .catch(error => {
  60. dispatch({
  61. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  62. error
  63. });
  64. });
  65. };
  66. }