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

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