選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

actions.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @flow
  2. import { openDialog } from '../../features/base/dialog';
  3. import {
  4. SET_INFO_DIALOG_VISIBILITY,
  5. UPDATE_DIAL_IN_NUMBERS_FAILED,
  6. UPDATE_DIAL_IN_NUMBERS_SUCCESS
  7. } from './actionTypes';
  8. import { InviteDialog } from './components';
  9. declare var $: Function;
  10. /**
  11. * Opens the Invite Dialog.
  12. *
  13. * @returns {Function}
  14. */
  15. export function openInviteDialog() {
  16. return openDialog(InviteDialog);
  17. }
  18. /**
  19. * Opens the inline conference info dialog.
  20. *
  21. * @param {boolean} visible - Whether or not the dialog should be displayed.
  22. * @param {boolean} autoClose - Whether or not the dialog should automatically
  23. * close after a set period of time.
  24. * @returns {{
  25. * type: SET_INFO_DIALOG_VISIBILITY,
  26. * autoClose: boolean,
  27. * visible: boolean
  28. * }}
  29. */
  30. export function setInfoDialogVisibility(
  31. visible: boolean,
  32. autoClose: boolean = false) {
  33. return {
  34. type: SET_INFO_DIALOG_VISIBILITY,
  35. autoClose,
  36. visible
  37. };
  38. }
  39. /**
  40. * Sends AJAX requests for dial-in numbers and conference ID.
  41. *
  42. * @returns {Function}
  43. */
  44. export function updateDialInNumbers() {
  45. return (dispatch: Dispatch<*>, getState: Function) => {
  46. const state = getState();
  47. const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
  48. = state['features/base/config'];
  49. const mucURL = hosts && hosts.muc;
  50. if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
  51. // URLs for fetching dial in numbers not defined
  52. return;
  53. }
  54. const { room } = state['features/base/conference'];
  55. const conferenceIDURL
  56. = `${dialInConfCodeUrl}?conference=${room}@${mucURL}`;
  57. Promise.all([
  58. $.getJSON(dialInNumbersUrl),
  59. $.getJSON(conferenceIDURL)
  60. ])
  61. .then(([ dialInNumbers, { conference, id, message } ]) => {
  62. if (!conference || !id) {
  63. return Promise.reject(message);
  64. }
  65. dispatch({
  66. type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
  67. conferenceID: id,
  68. dialInNumbers
  69. });
  70. })
  71. .catch(error => {
  72. dispatch({
  73. type: UPDATE_DIAL_IN_NUMBERS_FAILED,
  74. error
  75. });
  76. });
  77. };
  78. }