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.5KB

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