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.

reducer.js 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { ReducerRegistry } from '../redux';
  2. import { SET_CONFIG } from './actionTypes';
  3. /**
  4. * The initial state of the feature base/config. The mandatory configuration to
  5. * be passed to JitsiMeetJS#init(). The app will download config.js from the
  6. * Jitsi Meet deployment and take its values into account but the values bellow
  7. * will be enforced (because they are essential to the correct execution of the
  8. * application).
  9. *
  10. * @type {Object}
  11. */
  12. const INITIAL_STATE = {
  13. // FIXME The support for audio levels in lib-jitsi-meet polls the statistics
  14. // of WebRTC at a short interval multiple times a second. Unfortunately,
  15. // React Native is slow to fetch these statistics from the native WebRTC
  16. // API, through the React Native bridge and eventually to JavaScript.
  17. // Because the audio levels are of no interest to the mobile app, it is
  18. // fastest to merely disable them.
  19. disableAudioLevels: true,
  20. // FIXME Lib-jitsi-meet uses HTML script elements to asynchronously load
  21. // certain pieces of JavaScript. Unfortunately, the technique doesn't work
  22. // on React Native (because there are no HTML elements in the first place).
  23. // Fortunately, these pieces of JavaScript currently involve third parties
  24. // and we can temporarily disable them (until we implement an alternative to
  25. // async script elements on React Native).
  26. disableThirdPartyRequests: true
  27. };
  28. ReducerRegistry.register(
  29. 'features/base/config',
  30. (state = INITIAL_STATE, action) => {
  31. switch (action.type) {
  32. case SET_CONFIG:
  33. return _setConfig(state, action);
  34. default:
  35. return state;
  36. }
  37. });
  38. /**
  39. * Reduces a specific Redux action SET_CONFIG of the feature
  40. * base/lib-jitsi-meet.
  41. *
  42. * @param {Object} state - The Redux state of the feature base/lib-jitsi-meet.
  43. * @param {Action} action - The Redux action SET_CONFIG to reduce.
  44. * @private
  45. * @returns {Object} The new state of the feature base/lib-jitsi-meet after the
  46. * reduction of the specified action.
  47. */
  48. function _setConfig(state, action) {
  49. return {
  50. ...action.config,
  51. // The config of INITIAL_STATE is meant to override the config
  52. // downloaded from the Jitsi Meet deployment because the former contains
  53. // values that are mandatory.
  54. //
  55. // FIXME At the time of this writing the hard-coded overriding values
  56. // are specific to mobile/React Native but the source code here is
  57. // executed on Web/React as well. The latter is not a practical problem
  58. // right now because the rest of the Web/React source code does not read
  59. // the overridden properties/values, it still relies on the global
  60. // variable config.
  61. ...INITIAL_STATE
  62. };
  63. }