Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

actions.ts 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import {
  2. appNavigate,
  3. maybeRedirectToWelcomePage
  4. } from '../app/actions';
  5. import { IStore } from '../app/types';
  6. import { conferenceLeft, setPassword } from '../base/conference/actions';
  7. import { JITSI_CONFERENCE_URL_KEY } from '../base/conference/constants';
  8. import { IJitsiConference } from '../base/conference/reducer';
  9. import { hideDialog, openDialog } from '../base/dialog/actions';
  10. import { SecurityDialog } from '../security/components/security-dialog';
  11. import PasswordRequiredPrompt from './components/PasswordRequiredPrompt';
  12. /**
  13. * Cancels a prompt for a password to join a specific conference/room.
  14. *
  15. * @param {JitsiConference} conference - The {@code JitsiConference} requesting
  16. * the password to join.
  17. * @protected
  18. * @returns {Function}
  19. */
  20. export function _cancelPasswordRequiredPrompt(conference: any) {
  21. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  22. if (typeof APP !== 'undefined') {
  23. // when we are redirecting the library should handle any
  24. // unload and clean of the connection.
  25. APP.API.notifyReadyToClose();
  26. dispatch(maybeRedirectToWelcomePage());
  27. return;
  28. }
  29. // Canceling PasswordRequiredPrompt is to navigate the app/user to
  30. // WelcomePage. In other words, the canceling invalidates the
  31. // locationURL. Make sure that the canceling indeed has the intent to
  32. // invalidate the locationURL.
  33. const state = getState();
  34. if (conference === state['features/base/conference'].passwordRequired
  35. && conference[JITSI_CONFERENCE_URL_KEY]
  36. === state['features/base/connection'].locationURL) {
  37. // XXX The error associated with CONFERENCE_FAILED was marked as
  38. // recoverable by the feature room-lock and, consequently,
  39. // recoverable-aware features such as mobile's external-api did not
  40. // deliver the CONFERENCE_FAILED to the SDK clients/consumers. Since
  41. // the app/user is going to nativate to WelcomePage, the SDK
  42. // clients/consumers need an event.
  43. dispatch(conferenceLeft(conference));
  44. dispatch(appNavigate(undefined));
  45. }
  46. };
  47. }
  48. /**
  49. * Ends a (user) request to lock a specific conference/room.
  50. *
  51. * @param {JitsiConference} conference - The JitsiConference to lock.
  52. * @param {string|undefined} password - The password with which the specified
  53. * conference is to be locked or undefined to cancel the (user) request to lock
  54. * the specified conference.
  55. * @returns {Function}
  56. */
  57. export function endRoomLockRequest(
  58. conference: IJitsiConference,
  59. password?: string) {
  60. return (dispatch: IStore['dispatch']) => {
  61. const setPassword_
  62. = password
  63. ? dispatch(setPassword(conference, conference.lock, password))
  64. : Promise.resolve();
  65. const endRoomLockRequest_ = () => dispatch(hideDialog(SecurityDialog));
  66. setPassword_.then(endRoomLockRequest_, endRoomLockRequest_);
  67. };
  68. }
  69. /**
  70. * Begins a prompt for a password to join a specific conference/room.
  71. *
  72. * @param {JitsiConference} conference - The {@code JitsiConference}
  73. * requesting the password to join.
  74. * @protected
  75. * @returns {{
  76. * type: OPEN_DIALOG,
  77. * component: Component,
  78. * props: PropTypes
  79. * }}
  80. */
  81. export function _openPasswordRequiredPrompt(conference: IJitsiConference) {
  82. return openDialog(PasswordRequiredPrompt, { conference });
  83. }
  84. /**
  85. * Unlocks the current jitsi conference.
  86. *
  87. * @returns {Function}
  88. */
  89. export function unlockRoom() {
  90. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  91. const { conference } = getState()['features/base/conference'];
  92. return dispatch(setPassword(
  93. conference,
  94. conference?.lock,
  95. ''
  96. ));
  97. };
  98. }