Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

reducer.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. ...INITIAL_STATE
  55. };
  56. }