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

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