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

actions.web.ts 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 => j && dispatch(setJWT(j)))
  33. .then(() => dispatch(_connectInternal(id, password)));
  34. }
  35. // used by jibri
  36. const usernameOverride = jitsiLocalStorage.getItem('xmpp_username_override');
  37. const passwordOverride = jitsiLocalStorage.getItem('xmpp_password_override');
  38. if (usernameOverride && usernameOverride.length > 0) {
  39. id = usernameOverride; // eslint-disable-line no-param-reassign
  40. }
  41. if (passwordOverride && passwordOverride.length > 0) {
  42. password = passwordOverride; // eslint-disable-line no-param-reassign
  43. }
  44. return dispatch(_connectInternal(id, password));
  45. };
  46. }
  47. /**
  48. * Closes connection.
  49. *
  50. * @param {boolean} [requestFeedback] - Whether to attempt showing a
  51. * request for call feedback.
  52. * @param {string} [feedbackTitle] - The feedback title.
  53. * @returns {Function}
  54. */
  55. export function hangup(requestFeedback = false, feedbackTitle?: string) {
  56. // XXX For web based version we use conference hanging up logic from the old app.
  57. return async (dispatch: IStore['dispatch']) => {
  58. if (LocalRecordingManager.isRecordingLocally()) {
  59. dispatch(stopLocalVideoRecording());
  60. dispatch(showWarningNotification({
  61. titleKey: 'localRecording.stopping',
  62. descriptionKey: 'localRecording.wait'
  63. }, NOTIFICATION_TIMEOUT_TYPE.STICKY));
  64. // wait 1000ms for the recording to end and start downloading
  65. await new Promise(res => {
  66. setTimeout(res, 1000);
  67. });
  68. }
  69. return APP.conference.hangup(requestFeedback, feedbackTitle);
  70. };
  71. }