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 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
  43. $.getJSON(fullUrl)
  44. .success(response =>
  45. dispatch({
  46. type: PHONE_NUMBER_CHECKED,
  47. response
  48. }))
  49. .error(error =>
  50. dispatch({
  51. type: DIAL_OUT_SERVICE_FAILED,
  52. error
  53. }));
  54. };
  55. }
  56. /**
  57. * Opens the dial-out dialog.
  58. *
  59. * @returns {Function}
  60. */
  61. export function openDialOutDialog() {
  62. return openDialog(DialOutDialog);
  63. }
  64. /**
  65. * Sends an ajax request for dial-out country codes.
  66. *
  67. * @returns {Function}
  68. */
  69. export function updateDialOutCodes() {
  70. return (dispatch, getState) => {
  71. const { dialOutCodesUrl } = getState()['features/base/config'];
  72. $.getJSON(dialOutCodesUrl)
  73. .success(response =>
  74. dispatch({
  75. type: DIAL_OUT_CODES_UPDATED,
  76. response
  77. }))
  78. .error(error =>
  79. dispatch({
  80. type: DIAL_OUT_SERVICE_FAILED,
  81. error
  82. }));
  83. };
  84. }