您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 3.9KB

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