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

actions.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { openDialog } from '../../features/base/dialog';
  2. import {
  3. DIAL_OUT_CANCELED,
  4. DIAL_OUT_CODES_UPDATED,
  5. DIAL_OUT_SERVICE_FAILED,
  6. PHONE_NUMBER_CHECKED
  7. } from './actionTypes';
  8. import { DialOutDialog } from './components';
  9. declare var $: Function;
  10. declare var config: Object;
  11. /**
  12. * Dials the given number.
  13. *
  14. * @returns {Function}
  15. */
  16. export function cancel() {
  17. return {
  18. type: DIAL_OUT_CANCELED
  19. };
  20. }
  21. /**
  22. * Dials the given number.
  23. *
  24. * @param {string} dialNumber - The number to dial.
  25. * @returns {Function}
  26. */
  27. export function dial(dialNumber) {
  28. return (dispatch, getState) => {
  29. const { conference } = getState()['features/base/conference'];
  30. conference.dial(dialNumber);
  31. };
  32. }
  33. /**
  34. * Sends an ajax request for dial-out country codes.
  35. *
  36. * @param {string} dialNumber - The dial number to check for validity.
  37. * @returns {Function}
  38. */
  39. export function checkDialNumber(dialNumber) {
  40. return (dispatch, getState) => {
  41. const { dialOutAuthUrl } = getState()['features/base/config'];
  42. if (!dialOutAuthUrl) {
  43. // no auth url, let's say it is valid
  44. const response = {};
  45. response.allow = true;
  46. dispatch({
  47. type: PHONE_NUMBER_CHECKED,
  48. response
  49. });
  50. return;
  51. }
  52. const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
  53. $.getJSON(fullUrl)
  54. .success(response =>
  55. dispatch({
  56. type: PHONE_NUMBER_CHECKED,
  57. response
  58. }))
  59. .error(error =>
  60. dispatch({
  61. type: DIAL_OUT_SERVICE_FAILED,
  62. error
  63. }));
  64. };
  65. }
  66. /**
  67. * Opens the dial-out dialog.
  68. *
  69. * @returns {Function}
  70. */
  71. export function openDialOutDialog() {
  72. return openDialog(DialOutDialog);
  73. }
  74. /**
  75. * Sends an ajax request for dial-out country codes.
  76. *
  77. * @returns {Function}
  78. */
  79. export function updateDialOutCodes() {
  80. return (dispatch, getState) => {
  81. const { dialOutCodesUrl } = getState()['features/base/config'];
  82. if (!dialOutCodesUrl) {
  83. return;
  84. }
  85. $.getJSON(dialOutCodesUrl)
  86. .success(response =>
  87. dispatch({
  88. type: DIAL_OUT_CODES_UPDATED,
  89. response
  90. }))
  91. .error(error =>
  92. dispatch({
  93. type: DIAL_OUT_SERVICE_FAILED,
  94. error
  95. }));
  96. };
  97. }