Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

actions.web.ts 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * @param {boolean} [notifyOnConferenceTermination] - Whether to notify
  56. * the user on conference termination.
  57. * @returns {Function}
  58. */
  59. export function hangup(requestFeedback = false, feedbackTitle?: string, notifyOnConferenceTermination?: boolean) {
  60. // XXX For web based version we use conference hanging up logic from the old app.
  61. return async (dispatch: IStore['dispatch']) => {
  62. if (LocalRecordingManager.isRecordingLocally()) {
  63. dispatch(stopLocalVideoRecording());
  64. dispatch(showWarningNotification({
  65. titleKey: 'localRecording.stopping',
  66. descriptionKey: 'localRecording.wait'
  67. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  68. // wait 1000ms for the recording to end and start downloading
  69. await new Promise(res => {
  70. setTimeout(res, 1000);
  71. });
  72. }
  73. return APP.conference.hangup(requestFeedback, feedbackTitle, notifyOnConferenceTermination);
  74. };
  75. }