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 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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'.
  10. *
  11. * @type {{
  12. * initializationError: null,
  13. * initialized: boolean
  14. * }}
  15. */
  16. const INITIAL_STATE = {
  17. config: {
  18. // FIXME Lib-jitsi-meet uses HTML script elements to asynchronously
  19. // load certain pieces of JavaScript. Unfortunately, the technique
  20. // doesn't work on React Native (because there are no HTML elements
  21. // in the first place). Fortunately, these pieces of JavaScript
  22. // currently involve third parties and we can temporarily disable
  23. // them (until we implement an alternative to async script elements
  24. // on React Native).
  25. disableThirdPartyRequests: true
  26. },
  27. initializationError: null,
  28. initialized: false
  29. };
  30. ReducerRegistry.register(
  31. 'features/base/lib',
  32. (state = INITIAL_STATE, action) => {
  33. switch (action.type) {
  34. case LIB_DISPOSED:
  35. return INITIAL_STATE;
  36. case LIB_INIT_ERROR:
  37. return {
  38. ...state,
  39. initializationError: action.lib.error,
  40. initialized: false
  41. };
  42. case LIB_INITIALIZED:
  43. return {
  44. ...state,
  45. initializationError: null,
  46. initialized: true
  47. };
  48. case SET_CONFIG:
  49. return {
  50. ...state,
  51. config: {
  52. ...action.config,
  53. ...state.config
  54. }
  55. };
  56. default:
  57. return state;
  58. }
  59. });