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 1.9KB

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