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.web.ts 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // @ts-expect-error
  2. import { jitsiLocalStorage } from '@jitsi/js-utils';
  3. import { IStore } from '../../app/types';
  4. import { getCustomerDetails } from '../../jaas/actions.any';
  5. import { getJaasJWT, isVpaasMeeting } from '../../jaas/functions';
  6. import { showWarningNotification } from '../../notifications/actions';
  7. import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
  8. import { stopLocalVideoRecording } from '../../recording/actions.any';
  9. import LocalRecordingManager from '../../recording/components/Recording/LocalRecordingManager.web';
  10. import { setJWT } from '../jwt/actions';
  11. import { _connectInternal } from './actions.any';
  12. export * from './actions.any';
  13. /**
  14. * Opens new connection.
  15. *
  16. * @param {string} [id] - The XMPP user's ID (e.g. {@code user@server.com}).
  17. * @param {string} [password] - The XMPP user's password.
  18. * @returns {Function}
  19. */
  20. export function connect(id?: string, password?: string) {
  21. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  22. const state = getState();
  23. const { jwt } = state['features/base/jwt'];
  24. const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
  25. if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {
  26. return dispatch(getCustomerDetails())
  27. .then(() => {
  28. if (!jwt) {
  29. return getJaasJWT(state);
  30. }
  31. })
  32. .then(j => {
  33. j && dispatch(setJWT(j));
  34. return dispatch(_connectInternal(id, password));
  35. });
  36. }
  37. // used by jibri
  38. const usernameOverride = jitsiLocalStorage.getItem('xmpp_username_override');
  39. const passwordOverride = jitsiLocalStorage.getItem('xmpp_password_override');
  40. if (usernameOverride && usernameOverride.length > 0) {
  41. id = usernameOverride; // eslint-disable-line no-param-reassign
  42. }
  43. if (passwordOverride && passwordOverride.length > 0) {
  44. password = passwordOverride; // eslint-disable-line no-param-reassign
  45. }
  46. return dispatch(_connectInternal(id, password));
  47. };
  48. }
  49. /**
  50. * Closes connection.
  51. *
  52. * @param {boolean} [requestFeedback] - Whether to attempt showing a
  53. * request for call feedback.
  54. * @param {string} [feedbackTitle] - The feedback title.
  55. * @returns {Function}
  56. */
  57. export function hangup(requestFeedback = false, feedbackTitle?: string) {
  58. // XXX For web based version we use conference hanging up logic from the old app.
  59. return async (dispatch: IStore['dispatch']) => {
  60. if (LocalRecordingManager.isRecordingLocally()) {
  61. dispatch(stopLocalVideoRecording());
  62. dispatch(showWarningNotification({
  63. titleKey: 'localRecording.stopping',
  64. descriptionKey: 'localRecording.wait'
  65. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  66. // wait 1000ms for the recording to end and start downloading
  67. await new Promise(res => {
  68. setTimeout(res, 1000);
  69. });
  70. }
  71. return APP.conference.hangup(requestFeedback, feedbackTitle);
  72. };
  73. }