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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // @flow
  2. import {
  3. BEGIN_ADD_PEOPLE,
  4. UPDATE_DIAL_IN_NUMBERS_FAILED,
  5. UPDATE_DIAL_IN_NUMBERS_SUCCESS
  6. } from './actionTypes';
  7. import { getDialInConferenceID, getDialInNumbers } from './functions';
  8. /**
  9. * Creates a (redux) action to signal that a click/tap has been performed on
  10. * {@link InviteButton} and that the execution flow for adding/inviting people
  11. * to the current conference/meeting is to begin.
  12. *
  13. * @returns {{
  14. * type: BEGIN_ADD_PEOPLE
  15. * }}
  16. */
  17. export function beginAddPeople() {
  18. return {
  19. type: BEGIN_ADD_PEOPLE
  20. };
  21. }
  22. /**
  23. * Sends AJAX requests for dial-in numbers and conference ID.
  24. *
  25. * @returns {Function}
  26. */
  27. export function updateDialInNumbers() {
  28. return (dispatch: Dispatch<*>, getState: Function) => {
  29. const state = getState();
  30. const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
  31. = state['features/base/config'];
  32. const mucURL = hosts && hosts.muc;
  33. if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
  34. // URLs for fetching dial in numbers not defined
  35. return;
  36. }
  37. const { room } = state['features/base/conference'];
  38. Promise.all([
  39. getDialInNumbers(dialInNumbersUrl),
  40. getDialInConferenceID(dialInConfCodeUrl, room, mucURL)
  41. ])
  42. .then(([ dialInNumbers, { conference, id, message } ]) => {
  43. if (!conference || !id) {
  44. return Promise.reject(message);
  45. }
  46. dispatch({
  47. type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
  48. conferenceID: id,
  49. dialInNumbers
  50. });
  51. })
  52. .catch(error => {
  53. dispatch({
  54. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  55. error
  56. });
  57. });
  58. };
  59. }