選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

reducer.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { ReducerRegistry } from '../redux';
  2. import {
  3. LIB_DISPOSED,
  4. LIB_INIT_ERROR,
  5. LIB_INITIALIZED,
  6. SET_CONFIG
  7. } from './actionTypes';
  8. /**
  9. * Initial state of 'features/base/lib-jitsi-meet'.
  10. *
  11. * @type {{
  12. * initializationError: null,
  13. * initialized: boolean
  14. * }}
  15. */
  16. const INITIAL_STATE = {
  17. config: {
  18. // FIXME The support for audio levels in lib-jitsi-meet polls the
  19. // statistics of WebRTC at a short interval multiple times a second.
  20. // Unfortunately, React Native is slow to fetch these statistics from
  21. // the native WebRTC API, through the React Native bridge and eventually
  22. // to JavaScript. Because the audio levels are of no interest to the
  23. // mobile app, it is fastest to merely disable them.
  24. disableAudioLevels: true,
  25. // FIXME Lib-jitsi-meet uses HTML script elements to asynchronously load
  26. // certain pieces of JavaScript. Unfortunately, the technique doesn't
  27. // work on React Native (because there are no HTML elements in the first
  28. // place). Fortunately, these pieces of JavaScript currently involve
  29. // third parties and we can temporarily disable them (until we implement
  30. // an alternative to async script elements on React Native).
  31. disableThirdPartyRequests: true
  32. },
  33. initializationError: null,
  34. initialized: false
  35. };
  36. ReducerRegistry.register(
  37. 'features/base/lib-jitsi-meet',
  38. (state = INITIAL_STATE, action) => {
  39. switch (action.type) {
  40. case LIB_DISPOSED:
  41. return INITIAL_STATE;
  42. case LIB_INIT_ERROR:
  43. return {
  44. ...state,
  45. initializationError: action.lib.error,
  46. initialized: false
  47. };
  48. case LIB_INITIALIZED:
  49. return {
  50. ...state,
  51. initializationError: null,
  52. initialized: true
  53. };
  54. case SET_CONFIG:
  55. return _setConfig(state, action);
  56. default:
  57. return state;
  58. }
  59. });
  60. /**
  61. * Reduces a specific Redux action SET_CONFIG of the feature
  62. * base/lib-jitsi-meet.
  63. *
  64. * @param {Object} state - The Redux state of the feature base/lib-jitsi-meet.
  65. * @param {Action} action - The Redux action SET_CONFIG to reduce.
  66. * @private
  67. * @returns {Object} The new state of the feature base/lib-jitsi-meet after the
  68. * reduction of the specified action.
  69. */
  70. function _setConfig(state, action) {
  71. return {
  72. ...state,
  73. config: {
  74. // The final config is the result of augmenting the default config
  75. // with whatever the deployment has chosen to override/overwrite.
  76. ...INITIAL_STATE.config,
  77. ...action.config
  78. }
  79. };
  80. }