您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 { 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. * Sends AJAX requests for dial-in numbers and conference ID.
  19. *
  20. * @returns {Function}
  21. */
  22. export function updateDialInNumbers() {
  23. return (dispatch, getState) => {
  24. const state = getState();
  25. const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
  26. = state['features/base/config'];
  27. const mucURL = hosts && hosts.muc;
  28. if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
  29. dispatch({
  30. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  31. error: 'URLs for fetching dial in numbers not properly defined'
  32. });
  33. return;
  34. }
  35. const { room } = state['features/base/conference'];
  36. const conferenceIDURL
  37. = `${dialInConfCodeUrl}?conference=${room}@${mucURL}`;
  38. Promise.all([
  39. $.getJSON(dialInNumbersUrl),
  40. $.getJSON(conferenceIDURL)
  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. }