You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.js 2.1KB

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