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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 { AddPeopleDialog, 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 Add People Dialog.
  19. *
  20. * @returns {Function}
  21. */
  22. export function openAddPeopleDialog() {
  23. return openDialog(AddPeopleDialog);
  24. }
  25. /**
  26. * Opens the inline conference info dialog.
  27. *
  28. * @param {boolean} visible - Whether or not the dialog should be displayed.
  29. * @returns {{
  30. * type: SET_INFO_DIALOG_VISIBILITY,
  31. * visible: boolean
  32. * }}
  33. */
  34. export function setInfoDialogVisibility(visible) {
  35. return {
  36. type: SET_INFO_DIALOG_VISIBILITY,
  37. visible
  38. };
  39. }
  40. /**
  41. * Sends AJAX requests for dial-in numbers and conference ID.
  42. *
  43. * @returns {Function}
  44. */
  45. export function updateDialInNumbers() {
  46. return (dispatch, getState) => {
  47. const state = getState();
  48. const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
  49. = state['features/base/config'];
  50. const mucURL = hosts && hosts.muc;
  51. if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
  52. // URLs for fetching dial in numbers not defined
  53. return;
  54. }
  55. const { room } = state['features/base/conference'];
  56. const conferenceIDURL
  57. = `${dialInConfCodeUrl}?conference=${room}@${mucURL}`;
  58. Promise.all([
  59. $.getJSON(dialInNumbersUrl),
  60. $.getJSON(conferenceIDURL)
  61. ])
  62. .then(([ dialInNumbers, { conference, id, message } ]) => {
  63. if (!conference || !id) {
  64. return Promise.reject(message);
  65. }
  66. dispatch({
  67. type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
  68. conferenceID: id,
  69. dialInNumbers
  70. });
  71. })
  72. .catch(error => {
  73. dispatch({
  74. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  75. error
  76. });
  77. });
  78. };
  79. }