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

actions.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. dispatch({
  38. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  39. error: 'URLs for fetching dial in numbers not properly defined'
  40. });
  41. return;
  42. }
  43. const { room } = state['features/base/conference'];
  44. const conferenceIDURL
  45. = `${dialInConfCodeUrl}?conference=${room}@${mucURL}`;
  46. Promise.all([
  47. $.getJSON(dialInNumbersUrl),
  48. $.getJSON(conferenceIDURL)
  49. ])
  50. .then(([ dialInNumbers, { conference, id, message } ]) => {
  51. if (!conference || !id) {
  52. return Promise.reject(message);
  53. }
  54. dispatch({
  55. type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
  56. conferenceID: id,
  57. dialInNumbers
  58. });
  59. })
  60. .catch(error => {
  61. dispatch({
  62. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  63. error
  64. });
  65. });
  66. };
  67. }