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

actions.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import JitsiMeetJS from './';
  2. import {
  3. LIB_DISPOSED,
  4. LIB_INIT_ERROR,
  5. LIB_INITIALIZED,
  6. SET_CONFIG
  7. } from './actionTypes';
  8. /**
  9. * Disposes lib-jitsi-meet.
  10. *
  11. * @returns {Function}
  12. */
  13. export function disposeLib() {
  14. // XXX We're wrapping it with Promise, because:
  15. // a) to be better aligned with initLib() method, which is async.
  16. // b) as currently there is no implementation for it in lib-jitsi-meet, and
  17. // there is a big chance it will be async.
  18. // TODO Currently, lib-jitsi-meet doesn't have any functionality to
  19. // dispose itself.
  20. return dispatch => {
  21. dispatch({ type: LIB_DISPOSED });
  22. return Promise.resolve();
  23. };
  24. }
  25. /**
  26. * Initializes lib-jitsi-meet with passed configuration.
  27. *
  28. * @returns {Function}
  29. */
  30. export function initLib() {
  31. return (dispatch, getState) => {
  32. const config = getState()['features/base/lib-jitsi-meet'].config;
  33. if (!config) {
  34. throw new Error('Cannot initialize lib-jitsi-meet without config');
  35. }
  36. // XXX Temporarily until conference.js is moved to the React app we
  37. // shouldn't use JitsiMeetJS from the React app.
  38. if (typeof APP !== 'undefined') {
  39. return Promise.resolve();
  40. }
  41. return JitsiMeetJS.init(config)
  42. .then(() => dispatch({ type: LIB_INITIALIZED }))
  43. .catch(error => {
  44. dispatch({
  45. type: LIB_INIT_ERROR,
  46. lib: { error }
  47. });
  48. // TODO Handle LIB_INIT_ERROR error somewhere instead.
  49. console.error('lib-jitsi-meet failed to init due to ', error);
  50. throw error;
  51. });
  52. };
  53. }
  54. /**
  55. * Sets config.
  56. *
  57. * @param {Object} config - Config object accepted by JitsiMeetJS#init()
  58. * method.
  59. * @returns {{
  60. * type: SET_CONFIG,
  61. * config: Object
  62. * }}
  63. */
  64. export function setConfig(config) {
  65. return {
  66. type: SET_CONFIG,
  67. config
  68. };
  69. }